diff --git a/libguile/symbols.c b/libguile/symbols.c index c77749f11..9a59b6a8e 100644 --- a/libguile/symbols.c +++ b/libguile/symbols.c @@ -443,6 +443,32 @@ scm_take_locale_symbol (char *sym) 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 scm_symbols_prehistory () { diff --git a/libguile/symbols.h b/libguile/symbols.h index 8f96d65e5..6106f9ef1 100644 --- a/libguile/symbols.h +++ b/libguile/symbols.h @@ -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_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_symboln (const char *str, size_t len); 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_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. */ SCM_INTERNAL unsigned long scm_i_hash_symbol (SCM obj, unsigned long n,