Site icon Learn C++

Learn About Delimiters (Tokens) in Modern C++ On Windows

Delimiters (token term also used) are characters which separates strings between each of them. For example spaces, comas and other symbols can be used as a delimiter char to separate strings between them . Normaly in C++ strtok() were being used in C++, that is used with chars. In Modern C++, strings are now UnicodeStrings, TStringlists has some property to extract strings. If you are new to UnicodeStrings please check here

Example procedure below shows how to split a UnicodeString to a StringList which has delimited UnicodeStrings

[crayon-674193f17a447823979999/]

We can easily use this In C++ Builder. Create a new “Multi-Device C++ Builder Project” , Add a Memo and a Button on the Form of Project. Double click to Button, add this split procedure and OnClick() event of Button as below;

[crayon-674193f17a452066472361/]

Header of this project will be automatically like this.

[crayon-674193f17a456141331579/]

We can use any UnicodeString Chars as given above in L’ ‘ format. This method supports UnicodeStrings, because of this it is much more modern than classic strtok() function. Instead of this split(…) definition, we can also define this function as a member of Form like this;

[crayon-674193f17a457277305103/]

This time this split procedure should be defined as a a public member in public: definitions of Form1 class as below;

[crayon-674193f17a45a337333194/]

Using Delimiters globally in all languages requires to use of UnicodeStrings, and sometimes analyzing these text forms highly needs this kind of new modern methods. We think that this example will help you to analyze Unicode text forms.

Exit mobile version