Subject: | const char* is _not_ "raw" |
Date: | Sat, 20 Sep 2008 05:27:10 +0200 |
To: | bug-Glib [...] rt.cpan.org |
From: | Marc Lehmann <schmorp [...] schmorp.de> |
(Glib 1.183)
Glib uses constructs like these (comment from origianl file):
### note the use of raw const char* here.
gchar_own * g_filename_display_name (const char * filename);
however, there is nothing "raw" here, but instead "random" - const char *
gives the *internal* representation of the string, which might either be
utf-8 encoding or octet-encoding.
The problem is that the knowledge of how the characters are encoded is
thrown away.
For example, Glib::filename_display_name returns *different* strings,
depending on whether any function expecting a GPerlFilename is called
first (as that upgrades the string), and filename_display_name doesn't
look at the encoding info.
In general, any use of "const char *" is broken *unless* the encoding of
the underlying SV is being checked.
--
The choice of a Deliantra, the free code+content MORPG
-----==- _GNU_ http://www.deliantra.net
----==-- _ generation
---==---(_)__ __ ____ __ Marc Lehmann
--==---/ / _ \/ // /\ \/ / pcg@goof.com
-=====/_/_//_/\_,_/ /_/\_\