/If there is something wrong with this article, please give me some advice!
String Initialization
Define a variable of the unicode_string type. This is just an empty struct and we didn't allocate any memory to it. If you directly copy strings to them
An exception occurs. When we define a variable of this type, we should regard it as a wchar pointer without a "new" space, so we must go to the "new" space to give it.
Typedef struct
{
Ushort
Length;
Ushort
Maximumlength;
Pwchar
Buffer;
} Unicode_string,
* Punicode_string;
There are several methods:
1. rtlinitemptyunicodestring
Unicode_string STR;
Wchar wcsbuffer [1024] =
{0 };
Rtlemptyunicodestring (& STR, wcsbuffer,
Sizeof (wcsbuffer ));
This method is like defining a static string wchar
Wcsbuffer [1024] = {0 }.
2. dynamically apply for Space
Unicode_string STR;
Str. Buffer =
(Pwchar) exallocatepoolwithtag (nonpagepool, 1024, '123 ');
Str. Length = 0;
Str. maximumlength =
1024;
This method is like defining a wchar *
Pwcsbuffer = new wchar [1024];
After use, the memory must be released.
Exfreepool or exfreepoolwithtag.
3. Define the constant unicode_string
You can use the macro rtl_constant_string
Unicode_string STR =
Rtl_constant_string (L "My first string ");
Remember that this string cannot be modified, because it is like defining char
* STR = "123"; the string cannot be modified.
Copy string
Rtlcopyunicodestring (& DST,
& SRC );
String connection
Rtlappendunicodetostring (& DST, L "123 ");
Rtlappendunicodetounicodestring (& DST,
& SRC );
// The following table is reprinted and cannot find the source. Sorry!
String operation functions used in the driver
Here, we will compare ANSI and Unicode.
compare
strcmp
strncmp
_ stricmp
_ strnicmp
rtlcomparestring
rtlequalstring
wcscmp
wcsncmp
_ wcsicmp
_ wcsnicmp
rtlcompareunicodestring
rtlequalunicodestring
rtlprefixunicodestring
initialize
_ strset
_ strnset
rtlinitansistring
rtlinitstring
_ wcsnset
rtlinitunicodestring
Search
strchr
strrchr
strspns
strstr
wcschr
wcsrchr
wcsspns
wcsstr
upper/lowercase
_ strlwr
_ strupr
rtlupperstring,
_ wcslwr
_ wcsupr
rtlupcaseunicodestring
character
isdigit
islower
isprint
isspace
isupper
isxdigit
tolower
toupper
rtlupperchar
towolower
towupper
rtlupcaseunicodestring
Format
sprintf
vsprintf
_ snprintf
_ vsnprintf
swprintf
_ snwprintf
String Conversion
atoi
atoll
_ ITOA
_ itow
rtlintegertounicodestring
rtlunicodestringtointeger
Operation
|
ANSI string functions
|
Unicode string functions
|
Length
|
Strlen
|
Wcslen
|
Concatenate
|
Strcat
Strncat
|
Wcscat
Wcsncat
Rtlappendunicodestringtostring
Rtlappendunicodetostring
|
Copy
|
Strcpy
Strncpy
Rtlcopystring
|
Wcscpy
Wcsncpy
Trlcopyunicodestring
|
Reverse
|
_ Strrev
|
_ Wcsrev
|
& Lt; TD width = "110" valign = "TOP" & gt; & Lt; TD width = "204" & gt; & Lt; TD width = "242" & gt;
& Lt; TD width = "110" valign = "TOP" & gt; & Lt; TD width = "204" & gt; & Lt; TD width = "242" & gt;
& Lt; TD width = "110" valign = "TOP" & gt; & Lt; TD width = "204" & gt; & Lt; TD width = "242" & gt;
& Lt; TD width = "110" valign = "TOP" & gt; & Lt; TD width = "204" & gt; & Lt; TD width = "242" & gt;
& Lt; TD width = "110" valign = "TOP" & gt; & Lt; TD width = "204" & gt; & Lt; TD width = "242" & gt;
& Lt; TD width = "110" valign = "TOP" & gt; & Lt; TD width = "204" & gt; & Lt; TD width = "242" & gt;
& Lt; TD width = "110" valign = "TOP" & gt; & Lt; TD width = "204" & gt; & Lt; TD width = "242" & gt;
Type conversion
|
Rtlansistringtounicodestring
Rtlansistringtounicodestring
|
Rtlunicodestringtoansistring
|
Memory release
|
Rtlfreeansistring
|
Rtlfreeunicodestring
|