]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
Add unrestricted local encoding support to tools
authorVMware, Inc <>
Thu, 17 Dec 2009 22:51:09 +0000 (14:51 -0800)
committerMarcelo Vanzin <mvanzin@vmware.com>
Thu, 17 Dec 2009 22:51:09 +0000 (14:51 -0800)
Tools needs to be able to use local encodings even if they are
not supported in our stripped down version of the ICU.  In tools
builds accept any encoding as valid provided we recognize it
and it is the default local encoding.  If the encoding is not
supported in our ICU, revert to using native OS conversions with
codesetOld.

Signed-off-by: Marcelo Vanzin <mvanzin@vmware.com>
open-vm-tools/lib/unicode/unicodeSimpleTypes.c

index a5ebde9ea85ae84bb8839a58bef1505e2e1f8864..696671fa6c35851cca3745d9ba6a089a88bc2910 100644 (file)
@@ -2379,8 +2379,14 @@ Unicode_EncodingEnumToName(StringEncoding encoding) // IN
  *      The StringEncoding enum value corresponding to the name, or
  *      STRING_ENCODING_UNKNOWN if the encoding name is not supported.
  *
+ *      Inside tools all recognized local encodings are supported.
+ *      If the local encoding is not available in our copy of ICU,
+ *      fall back to the guest's facilities for converting between 
+ *      the local encoding and UTF-8.
+ *
  * Side effects:
- *      None
+ *      In tools, finding an unsupported encoding disables ICU and
+ *      switches to codesetOld support.
  *
  *-----------------------------------------------------------------------------
  */
@@ -2394,7 +2400,16 @@ Unicode_EncodingNameToEnum(const char *encodingName) // IN
    if (idx < 0) {
       return STRING_ENCODING_UNKNOWN;
    }
-   return xRef[idx].isSupported ? xRef[idx].encoding : STRING_ENCODING_UNKNOWN;
+   if (xRef[idx].isSupported) {
+      return xRef[idx].encoding;
+   }
+#if defined(VMX86_TOOLS)
+   if (idx == UnicodeIANALookup(CodeSet_GetCurrentCodeSet())) {
+      CodeSet_DontUseIcu();
+      return xRef[idx].encoding;
+   }
+#endif
+   return STRING_ENCODING_UNKNOWN;
 }