StrGet() [AHK_L 46+]

Copies a string from a memory address, optionally converting it from a given code page.

String := StrGet(Source , Length , Encoding := None)

매개변수

Source

The memory address of the string.

The string is not required to be null-terminated if the Length parameter is specified.

Length

The length of the string, in characters. This can be omitted if the string is null-terminated.

Note: Omitting Length when the string is not null-terminated may cause an access violation which terminates the program, or some other undesired result. Specifying an incorrect length may produce unexpected behaviour.

Note: Embedded null characters are unsupported and will generally cause truncation of the string.

Encoding

The source encoding; for example, "UTF-8", "UTF-16" or "CP936". For numeric identifiers, the prefix "CP" can be omitted only if Length is specified. 빈 문자열이나 "CP0"을 지정하면 시스템 기본 ANSI 코드 페이지를 사용합니다.

반환 값

This function returns the copied or converted string. If the source encoding was specified correctly, the return value always uses the native encoding. It is always null-terminated, but the null-terminator is not included in the return value's length.

에러 처리

An empty string is returned if invalid parameters are detected, or if the conversion cannot be performed.

논평

Note that the return value is always in the native encoding of the current executable, whereas Encoding specifies how to interpret the string read from the given Source. If no Encoding is specified, the string is simply copied without any conversion taking place.

In other words, StrGet is used to retrieve text from a memory address, or convert it to a format the script can understand.

If conversion between code pages is necessary, the length of the return value may differ from the length of the source string.

String Encoding, StrPut(), Script Compatibility, FileEncoding, DllCall(), VarSetCapacity()

예제

LengthEncodingSource 다음에 직접적으로 지정할 수 있습니다. 그러나 그런 경우 Encoding은 절대로 숫치형이 되면 안됩니다.

str := StrGet(address, "cp0")  ; Code page 0, unspecified length
str := StrGet(address, n, 0)   ; Maximum n chars, code page 0
str := StrGet(address, 0)      ; Maximum 0 chars (always blank)