News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

UTF code point to UTF-8

Started by Fab, March 18, 2010, 04:02:49 PM

Previous topic - Next topic

Fab

Hi,

Before I try to write my own UTF code point (U+XXXXXX) to UTF-8 function I was wondering if there was already some functions written in the win API that could do this for me.
What I need it to do is convert a UTF code point into its 1,2,3 or 4 byte UTF-8 equivalent

I had a quick look at WideCharToMultiByte. but its says "Maps a UTF-16 (wide character) string to a new character string"
Does that mean UTF-16 has a direct correlation to UTF code points? if that is the case, and UTF-16 is just a 2byte wide character, how could this function handle any code points above U+FFFF ?

any help, even just pointing me in the right direction would be great! It's all abit confusingĀ  :dazzled:

ThanksĀ  :wink

donkey

You can use the codepage parameter in WideCharToMultiByte to change what the output will be. In Win32 surrogate pairs are supported extending the number of allowable values beyond the 65,536 characters allowed in the BMP.

http://msdn.microsoft.com/en-us/library/dd374081%28VS.85%29.aspx
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable