[Common-cvs] util encstr.cpp,1.9,1.10

[Common-cvs] util encstr.cpp,1.9,1.10

sfu at helixcommunity.org sfu at helixcommunity.org
Thu Feb 17 05:36:34 PST 2011


Update of /cvsroot/common/util
In directory cvs01.internal.helixcommunity.org:/tmp/cvs-serv24339

Modified Files:
	encstr.cpp 
Log Message:
bug 267340 fix - properly handle IsAsciiOnly for LOCAL encoding

Index: encstr.cpp
===================================================================
RCS file: /cvsroot/common/util/encstr.cpp,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- encstr.cpp	1 Sep 2010 19:59:39 -0000	1.9
+++ encstr.cpp	17 Feb 2011 13:36:32 -0000	1.10
@@ -97,6 +97,7 @@
         case HX_TEXT_ENCODING_TYPE_UNKNOWN:
         case HX_TEXT_ENCODING_TYPE_ISO8859_1:
         case HX_TEXT_ENCODING_TYPE_UTF8:
+        case HX_TEXT_ENCODING_TYPE_LOCAL:
         {
             UCHAR ch = 0;
             HXBOOL bSpace = FALSE;
@@ -146,6 +147,10 @@
             printf("utf16le");
             break;
 
+        case HX_TEXT_ENCODING_TYPE_LOCAL:
+            printf("local");
+            break;
+
         default:
             printf("(unhandled encoding type)");
             return FALSE;
@@ -208,6 +213,13 @@
         case HX_TEXT_ENCODING_TYPE_UTF8:
             return EncStrUtils::PrintTextUTF8(psz);
 
+        case HX_TEXT_ENCODING_TYPE_LOCAL:
+        {
+            // first construct UTF8
+            EncodedString es(EncStrUtils::ConvertToUTF8(psz, HX_TEXT_ENCODING_TYPE_UTF8));
+            return EncStrUtils::PrintTextUTF8(psz);
+        }
+
         default:
             break;
     }
@@ -331,6 +343,14 @@
             UINT32 count = 0;
             return IsUTF8StringAsciiOnly((const UINT8*)psz, MAX_UINT32, count);
         }
+        case HX_TEXT_ENCODING_TYPE_LOCAL:
+        {
+            UINT32 count = 0;
+            // logically this should be a separate function but it just happens
+            // to be that both local codepage encoding and UTF-8 uses MSB
+            // to indicate non-ascii code point. We took a shortcut here.
+            return IsUTF8StringAsciiOnly((const UINT8*)psz, MAX_UINT32, count);
+        }
         default:
             break;
     }
@@ -491,6 +511,7 @@
         }
         case HX_TEXT_ENCODING_TYPE_UTF8:
         case HX_TEXT_ENCODING_TYPE_ISO8859_1:
+        case HX_TEXT_ENCODING_TYPE_LOCAL:
         case HX_TEXT_ENCODING_TYPE_UNKNOWN:
         {
             return EncStrUtils::ByteLength(psz, enc, bCountNullTerm);
@@ -895,6 +916,7 @@
             case HX_TEXT_ENCODING_TYPE_UNKNOWN:
             case HX_TEXT_ENCODING_TYPE_ISO8859_1:
             case HX_TEXT_ENCODING_TYPE_UTF8:
+            case HX_TEXT_ENCODING_TYPE_LOCAL:
                 return ::StringEqualA(psz1, psz2);
 
             case HX_TEXT_ENCODING_TYPE_UTF16:
@@ -989,6 +1011,7 @@
             return bCountNullTerm ? m_totalByteLength : (m_totalByteLength - 2);
 
         case HX_TEXT_ENCODING_TYPE_UTF8:
+        case HX_TEXT_ENCODING_TYPE_LOCAL:
         case HX_TEXT_ENCODING_TYPE_ISO8859_1:
         case HX_TEXT_ENCODING_TYPE_UNKNOWN:
             return bCountNullTerm ? m_totalByteLength : (m_totalByteLength - 1);
@@ -1019,6 +1042,7 @@
             return len / 2;
 
         case HX_TEXT_ENCODING_TYPE_UTF8:
+        case HX_TEXT_ENCODING_TYPE_LOCAL:
         case HX_TEXT_ENCODING_TYPE_ISO8859_1:
         case HX_TEXT_ENCODING_TYPE_UNKNOWN:
             return len;




More information about the Common-cvs mailing list
 

Site Map   |   Terms of Use   |   Privacy Policy   |   Contact Us

Copyright © 1995-2007 RealNetworks, Inc. All rights reserved. RealNetworks and Helix are trademarks of RealNetworks.
All other trademarks or registered trademarks are the property of their respective holders.