Quantcast
Channel: Active questions tagged utf-8 - Stack Overflow
Viewing all articles
Browse latest Browse all 1057

How do I convert this string from a UTF16 file to match a string to UTF8 file? [closed]

$
0
0

I have situation where I am receiving a string that represents the data read from a UTF16 file. (I don't have control over the incoming data). The string looks like:

&#FF;&#FE;Y�F�T�8�1�1�...

The same file stored as UTF8 comes in as:

YFT811  {1500}02        P *{1510}...

Is there a way to convert the incoming string from a UTF16 file to match the string from the UTF8 file?

I tried:

// Get UTF16 bytes and convert UTF16 bytes to UTF8 bytesbyte[] utf16Bytes = Encoding.Unicode.GetBytes(utf16String);byte[] utf8Bytes = Encoding.Convert(Encoding.Unicode, Encoding.UTF8, utf16Bytes);// Return UTF8 bytes as ANSI stringreturn Encoding.Default.GetString(utf8Bytes);

But it just returned the same characters which makes sense, but not sure how to proceed.


Viewing all articles
Browse latest Browse all 1057

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>