.net - Unicode-to-string conversion in C# -


how can convert unicode value equivalent string?

for example, have "రమెశ్", , need function accepts unicode value , returns string.

i looking @ system.text.encoding.convert() function, not take in unicode value; takes 2 encodings , byte array.

i bascially have byte array need save in string field , come later , convert string first byte array.

so use byteconverter.getstring(bytearray) save byte array string, can't byte array.

try following:

byte[] bytes = ...;  string convertedutf8 = encoding.utf8.getstring(bytes); string convertedutf16 = encoding.unicode.getstring(bytes); // utf-16 

the other way around using `getbytes():

byte[] bytesutf8 = encoding.utf8.getbytes(convertedutf8); byte[] bytesutf16 = encoding.unicode.getbytes(convertedutf16); 

in encoding class, there more variants if need them.


Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

aspxgridview - Devexpress grid - header filter does not work if column is initially hidden -

c# - How to execute a particular part of code asynchronously in a class -