tags:

views:

62

answers:

1

Hi all,

I'm facing a character width problem in Japanese using glib::ustring.

I have this string: ウェッジパンプス

I want to convert it to: ウエッシパンプス

Using ustring::normalize, i get this string: ウェッジパンプス (in fact, here, each character with accent fills two characters width)

Is there a standard method to do this kind of processing? Is ICU better at doing this?

I need to convert Japanese strings into one of the two formats because a string in half width is different from the same one in full width.

+1  A: 

There is LCMapString that can do conversion between half/full width hiragana/katakana

AnsiString text = "変換する文字列"; //input text
//変換方法 how to convert
DWORD flags = LCMAP_FULLWIDTH; //全角文字にします。flag to convert to full width
//DWORD flags = LCMAP_HALFWIDTH; //半角文字にします)。to half width
//DWORD flags = LCMAP_HIRAGANA; //ひらがなにします。to hiragana
//DWORD flags = LCMAP_KATAKANA; //カタカナにします。to katakana
const int size = text.Length() * 2 + 1;
char* s = new char[size];
try
{
  ZeroMemory(s, size);
  LCMapString(GetUserDefaultLCID(),
              flags,
              text.c_str(),
              text.Length() + 1,
              s,
              size);
  AnsiString newtext = s; //変換した文字列 converted text
  return newtext;
}

ref:

S.Mark
That could work (I don't know), but I think that since the OP mentions `glib` he is not working on Windows.
Philipp
Thx but I'm developing under Ubuntu. Is there any equivalent of LCMapString? It seems pretty straight forward to use.