string_char_byte
Differences
This shows you the differences between two versions of the page.
Next revisionBoth sides next revision | |||
string_char_byte [2018/01/24 05:24] – created wolfgangriedmann | string_char_byte [2018/01/24 11:02] – wolfgangriedmann | ||
---|---|---|---|
Line 10: | Line 10: | ||
That was possible in VO or other Win32 languages, but it is not more correct in .NET. | That was possible in VO or other Win32 languages, but it is not more correct in .NET. | ||
In .NET, if reading binary data, you need to use variables defined as '' | In .NET, if reading binary data, you need to use variables defined as '' | ||
- | |||
< | < | ||
Line 16: | Line 15: | ||
If you are reading text data, you can read it into a string: | If you are reading text data, you can read it into a string: | ||
- | |||
< | < | ||
Line 23: | Line 21: | ||
Of course, you can convert for and back between strings and character arrays, but you need to specify the '' | Of course, you can convert for and back between strings and character arrays, but you need to specify the '' | ||
+ | To convert byte arrays to string, there are conversion functions. Please look at the Encoding class in the System.Text namespace in the .NET framework documentation. | ||
+ | < | ||
+ | local cString as string | ||
+ | |||
+ | System.Text.Encoding.Unicode.GetString( aBytes )</ | ||
+ | |||
+ | The inverse process is also possible: | ||
+ | < | ||
+ | local cString as string | ||
+ | |||
+ | aBytes := System.Text.Encoding.Unicode: | ||
+ | |||
+ | An array of char values can also be used instead of a string. | ||
+ | |||
+ | To build a string from a char array is very simple, you can use the constructor of the string class: | ||
+ | < | ||
+ | local cString as string | ||
+ | |||
+ | cString := String{ aChars }</ | ||
+ | |||
+ | For the inverse operation (from a string to a char array) you can use a method of the string class: | ||
+ | < | ||
+ | local aChars as char[] | ||
+ | |||
+ | aChars := cString: | ||
string_char_byte.txt · Last modified: 2018/08/20 04:04 by wolfgangriedmann