From: <ok...@us...> - 2004-08-30 11:52:53
|
Update of /cvsroot/crystal/CS/libs/csutil In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12275/libs/csutil Modified Files: inputdef.cpp Log Message: Added UTF-8 support for the definition strings and added a missing line to GetKeyString which caused it to fail. Index: inputdef.cpp =================================================================== RCS file: /cvsroot/crystal/CS/libs/csutil/inputdef.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- inputdef.cpp 12 Aug 2004 20:31:35 -0000 1.5 +++ inputdef.cpp 30 Aug 2004 11:52:14 -0000 1.6 @@ -319,9 +319,19 @@ else { containedType = csevKeyboard; - if (str.Length () == 1) keyboard.code = str.GetAt (0); - else keyboard.code = cook ? NameToCooked (str.GetData ()) - : NameToRaw (str.GetData ()); + + size_t skip = (size_t) csUnicodeTransform::UTF8Skip + ((utf8_char *) str.GetData (), str.Length ()); + if (skip == str.Length ()) + { + bool valid; + csUnicodeTransform::UTF8Decode + ((utf8_char *) str.GetData (), str.Length (), keyboard.code, &valid); + if (! valid) keyboard.code = 0; + } + else + keyboard.code = cook ? NameToCooked (str.GetData ()) + : NameToRaw (str.GetData ()); } } @@ -366,7 +376,12 @@ str.Append (keyboard.isCooked ? CookedToName (keyboard.code) : RawToName (keyboard.code)); else - str.Append ((char) keyboard.code); + { + char buf[CS_UC_MAX_UTF8_ENCODED]; + size_t size = csUnicodeTransform::EncodeUTF8 + (keyboard.code, (utf8_char *) buf, sizeof (buf)); + str.Append (buf, size); + } break; case csevMouseDown: @@ -469,6 +484,7 @@ const csKeyModifiers *mods, bool distinguishModifiers) { csInputDefinition def (CSMASK_ALLMODIFIERS, true); + def.containedType = csevKeyboard; def.keyboard.code = code; if (mods) def.modifiers = *mods; return def.ToString (distinguishModifiers); |