unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
* need: scm_from_{utf8,latin1}_{string,symbol,keyword}
@ 2010-09-06 11:23 Andy Wingo
  2010-09-06 16:28 ` Mike Gran
  2010-09-06 17:02 ` Ludovic Courtès
  0 siblings, 2 replies; 13+ messages in thread
From: Andy Wingo @ 2010-09-06 11:23 UTC (permalink / raw)
  To: guile-devel

Hi,

In our C source, we have been trained to use scm_from_locale_string et
al. This is usually the right thing to do when interacting with the
operating system.

However, when we have literals in C source code, I think this strategy
is incorrect. I write my C source code in UTF-8 or in ISO-8859-1, but if
the user is running in another locale, they will not load my
strings/symbols/keywords correctly.

The solution is to use functions that specify the locale. We don't have
those yet, but we do have the capability to write them
now. Specifically:

  scm_from_utf8_string
  scm_from_utf8_symbol
  scm_from_utf8_keyword

  scm_from_latin1_string
  scm_from_latin1_symbol
  scm_from_latin1_keyword

We probably also need the "n" variants.

It's unlikely that you have a known utf-32 string as a char*, but we
should probably also provide scm_t_uint16* and scm_t_uint32* variants
for utf16 and utf32.

                               * * *

We also have the converse problem: since the easiest (and recommended)
way to get a char* from a Scheme string has been scm_to_locale_string,
in many cases we give external libraries locale-encoded strings instead
of the encoding they expect.

For example, most GLib-based libraries expect utf-8 strings, but
Guile-GNOME ignorantly passes them the result of calling
scm_to_locale_string. Though this will work in UTF-8 locales, it's only
by accident.

So then we need, I think:

  scm_to_utf8_string
  scm_to_utf16_string
  scm_to_utf32_string

We need the "n" variants here too (perhaps more).

What do people think? Any takers on implementing this? :)

Cheers,

Andy
-- 
http://wingolog.org/



^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2010-09-08 21:04 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-09-06 11:23 need: scm_from_{utf8,latin1}_{string,symbol,keyword} Andy Wingo
2010-09-06 16:28 ` Mike Gran
2010-09-06 16:58   ` Andy Wingo
2010-09-06 17:02 ` Ludovic Courtès
2010-09-07 15:21   ` Mike Gran
2010-09-07 17:11     ` Ludovic Courtès
2010-09-07 22:05       ` Andy Wingo
2010-09-08 12:35         ` Ludovic Courtès
2010-09-08  3:26       ` Mike Gran
2010-09-08 12:11         ` Ludovic Courtès
2010-09-08 19:33           ` Andy Wingo
2010-09-08 21:04             ` Ludovic Courtès
2010-09-08 19:20         ` Andy Wingo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).