[Player-dev] CR: Don't convert client strings to utf8, as they (usually) are

[Player-dev] CR: Don't convert client strings to utf8, as they (usually) are

Greg Wright gwright at real.com
Wed Aug 25 14:53:58 PDT 2004


Notes below....


Ryan Gammon wrote:

 > The attached patch fixes 2839 Clip Details dialog shows corrupted high
 > ascii.
 >
 > The player was trying to convert strings to utf8 which were already in
 > utf8.
 >
 > On the gold branch, I've included a hack that checks copyright strings
 > for the (c) symbol, ascii 0xa9, which doesn't appear to get translated
 > to utf8. I'm planning to leave this hack out of HEAD, and log a bug on
 > the issue.
 >
 > QA can repro by opening a file with extended characters in the title,
 > and confirming that the clip details dialog box shows both the (c)
 > symbol and the extended characters correctly.
 >
 > For gold, aka hxclient_1_4_2_neptunex cvs branch, and for head.
 >
 >
 > ------------------------------------------------------------------------
 >
 > _______________________________________________
 > Player-dev mailing list
 > Player-dev at lists.helixcommunity.org
 > http://lists.helixcommunity.org/mailman/listinfo/player-dev
 >
 >Index: hxplayer.cpp
 >===================================================================
 >RCS file: /cvsroot/player/common/gtk/hxplayer.cpp,v
 >retrieving revision 1.37
 >diff -u -r1.37 hxplayer.cpp
 >--- hxplayer.cpp	19 Aug 2004 21:09:12 -0000	1.37
 >+++ hxplayer.cpp	25 Aug 2004 21:07:21 -0000
 >@@ -2198,9 +2198,6 @@
 >     gint int_value;
 >     gchar* str_value;
 >     bool result = FALSE;
 >-    gsize in;
 >-    gsize out;
 >-    gchar *utf8_val;
 >
 >     g_return_val_if_fail(player != NULL, FALSE);
 >     g_return_val_if_fail(HX_IS_PLAYER(player), FALSE);
 >@@ -2240,14 +2237,31 @@
 >             g_assert(buf_used == buf_desired);
 >             str_value[buf_used] = '\0';
 >
 >-            in = buf_used + 1;
 >-            out = 0;
 >-            utf8_val = g_convert(str_value, buf_used, "UTF-8", "ISO-8859-1", &in, &out, NULL);
 >-            g_assert(utf8_val);
 >-            g_free(str_value);
 >+            if(strcasecmp(key, "copyright") == 0)
 >+            {
 >+                gchar* copyright_symbol = strchr(str_value, 0xa9);
 >+
 >+                if(copyright_symbol)
 >+                {
 >+                    gint len;
 >+
 >+                    len = copyright_symbol - str_value;
 >+
 >+                    /* Make the copyright symbol proper utf-8 */
 >+                    gchar* utf8_val = (gchar*) g_try_malloc(buf_desired + 2);

Why does this g_try_malloc use buf_desired while the below version of
this same routine use strlen(buf)? Is this OK or a problem (I can see
how buf_desired is calculated?

Both versions only work after the word 'copyright'. Will you never
see a copyright symbol any other place?

Since you have 2 versions of the same code, you might want to consolidate
them into one common function if it doesn't a headache.

Rest looks good.
--greg.



 >+                    g_return_val_if_fail(utf8_val != FALSE, FALSE);
 >+
 >+                    strncpy(utf8_val, str_value, len);
 >+                    utf8_val[len] = 0xc2;
 >+                    utf8_val[len + 1] = 0xa9;
 >+                    strcpy(&utf8_val[len + 2], &str_value[len + 1]);
 >+                    g_free(str_value);
 >+                    str_value = utf8_val;
 >+                }
 >+            }
 >
 >             g_value_init(value, G_TYPE_STRING);
 >-            g_value_set_string_take_ownership(value, utf8_val);
 >+            g_value_set_string_take_ownership(value, str_value);
 >             break;
 >
 >         default:
 >Index: hxstatisticsobserver.cpp
 >===================================================================
 >RCS file: /cvsroot/player/common/gtk/hxstatisticsobserver.cpp,v
 >retrieving revision 1.5
 >diff -u -r1.5 hxstatisticsobserver.cpp
 >--- hxstatisticsobserver.cpp	9 Jul 2004 18:24:08 -0000	1.5
 >+++ hxstatisticsobserver.cpp	25 Aug 2004 21:07:21 -0000
 >@@ -71,13 +71,12 @@
 > static void hx_statistics_observer_finalize   (GObject*                   object);
 >
 > static void
 >-make_gvalue(GValue*              value,
 >+make_gvalue(const gchar*         key,
 >+            GValue*              value,
 >             int                  valueType,
 >             const unsigned char* szBuf)
 > {
 >-    gsize in;
 >-    gsize out;
 >-    gchar *utf8_val;
 >+    gchar *utf8_val = NULL;
 >     const gchar* buf = (const gchar*)szBuf;
 >
 >     switch(valueType)
 >@@ -88,10 +87,30 @@
 >             break;
 >
 >         case kValueTypeString:
 >-            in = strlen(buf) + 1;
 >-            out = 0;
 >-            utf8_val = g_convert(buf, in - 1, "UTF-8", "ISO-8859-1", &in, &out, NULL);
 >-            g_assert(utf8_val);
 >+            if(strcasecmp(key, "copyright") == 0)
 >+            {
 >+                gchar* copyright_symbol = strchr(buf, 0xa9);
 >+
 >+                if(copyright_symbol)
 >+                {
 >+                    gint len;
 >+
 >+                    len = copyright_symbol - buf;
 >+
 >+                    /* Make the copyright symbol proper utf-8 */
 >+                    utf8_val = (gchar*) g_try_malloc(strlen(buf) + 2);
 >+
 >+                    strncpy(utf8_val, buf, len);
 >+                    utf8_val[len] = 0xc2;
 >+                    utf8_val[len + 1] = 0xa9;
 >+                    strcpy(&utf8_val[len + 2], &buf[len + 1]);
 >+                }
 >+            }
 >+
 >+            if(!utf8_val)
 >+            {
 >+                utf8_val = g_strdup(buf);
 >+            }
 >
 >             g_value_init(value, G_TYPE_STRING);
 >             g_value_set_string_take_ownership(value, utf8_val);
 >@@ -112,7 +131,7 @@
 >     GValue value;
 >
 >     memset(&value, 0, sizeof(value));
 >-    make_gvalue(&value, valueType, pValue);
 >+    make_gvalue(pStatisticName, &value, valueType, pValue);
 >
 >     g_signal_emit(G_OBJECT(observerInfo), signals[STATISTIC_ADDED_SIGNAL], 0,
 >                   pStatisticName, (gpointer)&value);
 >@@ -129,7 +148,7 @@
 >     GValue value;
 >
 >     memset(&value, 0, sizeof(value));
 >-    make_gvalue(&value, valueType, pValue);
 >+    make_gvalue(pStatisticName, &value, valueType, pValue);
 >
 >     g_signal_emit(G_OBJECT(observerInfo), signals[STATISTIC_MODIFIED_SIGNAL], 0,
 >                   pStatisticName, (gpointer)&value);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 254 bytes
Desc: OpenPGP digital signature
Url : http://lists.helixcommunity.org/pipermail/player-dev/attachments/20040825/3ddf1b05/signature.bin


More information about the Player-dev 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.