summaryrefslogtreecommitdiff
path: root/libguile/strings.c
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2018-06-19 14:52:46 +0200
committerLudovic Courtès <ludo@gnu.org>2018-06-19 15:40:11 +0200
commit4f64bcd4d146618154d50202fc73d7083bf9b26a (patch)
tree0e03dd0b091f25440a2c84f26befa625c3647233 /libguile/strings.c
parent46bcbfa566de19a88e925bd0369e110cae5a6b03 (diff)
downloadguile-4f64bcd4d146618154d50202fc73d7083bf9b26a.tar.gz
Add 'scm_to_stringn' shortcut when converting to UTF-8.
* libguile/strings.c (scm_to_stringn): Call 'scm_to_utf8_stringn' when ENCODING == "UTF-8".
Diffstat (limited to 'libguile/strings.c')
-rw-r--r--libguile/strings.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/libguile/strings.c b/libguile/strings.c
index 5c49e33d8..5f35617a2 100644
--- a/libguile/strings.c
+++ b/libguile/strings.c
@@ -1,5 +1,5 @@
/* Copyright (C) 1995, 1996, 1998, 2000, 2001, 2004, 2006,
- * 2008-2016 Free Software Foundation, Inc.
+ * 2008-2016, 2018 Free Software Foundation, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
@@ -2172,6 +2172,12 @@ scm_to_stringn (SCM str, size_t *lenp, const char *encoding,
if (!scm_is_string (str))
scm_wrong_type_arg_msg (NULL, 0, str, "string");
+
+ if (c_strcasecmp (encoding, "UTF-8") == 0)
+ /* This is the most common case--e.g., when calling libc bindings
+ while using a UTF-8 locale. */
+ return scm_to_utf8_stringn (str, lenp);
+
ilen = scm_i_string_length (str);
if (ilen == 0)