1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-30 11:50:28 +02:00

add scm_from_{latin1,utf8}_symbol{n,}

* libguile/symbols.c (scm_from_latin1_symbol, scm_from_latin1_symboln)
  (scm_from_utf8_symbol, scm_from_utf8_symboln): New functions.
This commit is contained in:
Andy Wingo 2011-01-05 18:24:32 -06:00
parent d40e1ca893
commit ad5cbc470f
2 changed files with 42 additions and 0 deletions

View file

@ -443,6 +443,32 @@ scm_take_locale_symbol (char *sym)
return scm_take_locale_symboln (sym, (size_t)-1); return scm_take_locale_symboln (sym, (size_t)-1);
} }
SCM
scm_from_latin1_symbol (const char *sym)
{
return scm_from_latin1_symboln (sym, -1);
}
SCM
scm_from_latin1_symboln (const char *sym, size_t len)
{
SCM str = scm_from_latin1_stringn (sym, len);
return scm_i_str2symbol (str);
}
SCM
scm_from_utf8_symbol (const char *sym)
{
return scm_from_utf8_symboln (sym, -1);
}
SCM
scm_from_utf8_symboln (const char *sym, size_t len)
{
SCM str = scm_from_utf8_stringn (sym, len);
return scm_i_str2symbol (str);
}
void void
scm_symbols_prehistory () scm_symbols_prehistory ()
{ {

View file

@ -67,11 +67,27 @@ SCM_API SCM scm_symbol_pset_x (SCM s, SCM val);
SCM_API SCM scm_symbol_hash (SCM s); SCM_API SCM scm_symbol_hash (SCM s);
SCM_API SCM scm_gensym (SCM prefix); SCM_API SCM scm_gensym (SCM prefix);
/* Use locale encoding for user input, user output, or interacting with
the C library. Use latin-1 for ASCII, and for literals in source
code. Use UTF-8 for interaction with modern libraries which deal in
UTF-8. Otherwise use scm_to_stringn or scm_from_stringn, and
convert. */
SCM_API SCM scm_from_locale_symbol (const char *str); SCM_API SCM scm_from_locale_symbol (const char *str);
SCM_API SCM scm_from_locale_symboln (const char *str, size_t len); SCM_API SCM scm_from_locale_symboln (const char *str, size_t len);
SCM_API SCM scm_take_locale_symbol (char *sym); SCM_API SCM scm_take_locale_symbol (char *sym);
SCM_API SCM scm_take_locale_symboln (char *sym, size_t len); SCM_API SCM scm_take_locale_symboln (char *sym, size_t len);
SCM_API SCM scm_from_latin1_symbol (const char *str);
SCM_API SCM scm_from_latin1_symboln (const char *str, size_t len);
SCM_API SCM scm_take_latin1_symbol (char *sym);
SCM_API SCM scm_take_latin1_symboln (char *sym, size_t len);
SCM_API SCM scm_from_utf8_symbol (const char *str);
SCM_API SCM scm_from_utf8_symboln (const char *str, size_t len);
SCM_API SCM scm_take_utf8_symbol (char *sym);
SCM_API SCM scm_take_utf8_symboln (char *sym, size_t len);
/* internal functions. */ /* internal functions. */
SCM_INTERNAL unsigned long scm_i_hash_symbol (SCM obj, unsigned long n, SCM_INTERNAL unsigned long scm_i_hash_symbol (SCM obj, unsigned long n,