Click to See Complete Forum and Search --> : Half Width and Full Width Characters


humble_learner
August 11th, 2008, 08:29 AM
Hi,

How is it possible to detect half-width and full-width versions of the same Japanese katakana character ?

In the following code snippet - both the half width version and the full-width version result in the same hexa-decimal value. So, how could one distinguish the half-width version from the full width one.



int _tmain(int argc, _TCHAR* argv[])
{

cout<<"This is data wil both halfwidth and full width characters"<<endl;
stringstream s;
s<<hex<<(unsigned int)'カ';
cout<<"Full width ka : "<<s.str().c_str()<<endl;
stringstream s2;
s2<<hex<<(unsigned int)'カ';
cout<<"Half width ka : "<<s.str().c_str()<<endl;
}



Both the half-width version and the full-width version of the character 'ka' returns 834a as the hexa value.

humble_learner
August 11th, 2008, 08:56 AM
From what I could understand in the small article on the wikipedia page -

http://en.wikipedia.org/wiki/Halfwidth_and_Fullwidth_Forms,


it looks like the UNICODE representations of the half/fullwidth forms have different values for the same character.

So does that mean that we need to do a mbstowcs() or a mbtowc() and then maybe be in a position to distinguish ?