String operations in the driver

Source: Internet
Author: User

/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

& 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;

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

Type conversion

Rtlansistringtounicodestring

Rtlansistringtounicodestring

Rtlunicodestringtoansistring

Memory release

Rtlfreeansistring

Rtlfreeunicodestring

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.