develooper Front page | perl.cvs.parrot | Postings from December 2008

[svn:parrot] r34617 - branches/pdd22io_part3/src/pmc

From:
allison
Date:
December 29, 2008 22:16
Subject:
[svn:parrot] r34617 - branches/pdd22io_part3/src/pmc
Message ID:
20081230061611.8679CCB9FA@x12.develooper.com
Author: allison
Date: Mon Dec 29 22:16:10 2008
New Revision: 34617

Modified:
   branches/pdd22io_part3/src/pmc/stringhandle.pmc

Log:
[pdd22io] Modify StringHandle's 'readall' to create an empty UTF-8 string when
the encoding is set to 'utf8'.


Modified: branches/pdd22io_part3/src/pmc/stringhandle.pmc
==============================================================================
--- branches/pdd22io_part3/src/pmc/stringhandle.pmc	(original)
+++ branches/pdd22io_part3/src/pmc/stringhandle.pmc	Mon Dec 29 22:16:10 2008
@@ -172,7 +172,7 @@
         if (STRING_IS_NULL(old_string)) {
             GET_ATTR_encoding(INTERP, SELF, encoding);
             if (!STRING_IS_NULL(encoding) &&
-                    string_equal(INTERP, encoding, const_string(INTERP, "utf8")))
+                    string_equal(INTERP, encoding, const_string(INTERP, "utf8")) == 0)
                 new_string = string_make(INTERP, "", 0, "unicode", 0);
             else
                 new_string = string_from_cstring(INTERP, "", 0);
@@ -336,8 +336,15 @@
         STRING *string_result;
 
         GET_ATTR_stringhandle(INTERP, SELF, string_result);
-        if (STRING_IS_NULL(string_result))
-            string_result = const_string(INTERP, "");
+        if (STRING_IS_NULL(string_result)) {
+            STRING *encoding;
+            GET_ATTR_encoding(INTERP, SELF, encoding);
+            if (!STRING_IS_NULL(encoding) &&
+                    string_equal(INTERP, encoding, const_string(INTERP, "utf8")) == 0)
+                string_result = string_make(INTERP, "", 0, "unicode", 0);
+            else
+                string_result = const_string(INTERP, "");
+        }
         else
             string_result = string_copy(INTERP, string_result);
 



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About