From 1dbbb43729803068c320db353c129afb91d327b5 Mon Sep 17 00:00:00 2001 From: "Emden R. Gansner" Date: Fri, 24 Jan 2014 10:55:36 -0500 Subject: [PATCH] Extend ps_string to use a raw utf8 string, just escaping parentheses as necessary. This is needed for the lasi renderer. --- lib/common/psusershape.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/lib/common/psusershape.c b/lib/common/psusershape.c index 4a6e550a2..a68c24fd7 100644 --- a/lib/common/psusershape.c +++ b/lib/common/psusershape.c @@ -259,7 +259,14 @@ charsetOf (char* s) return r; } -char *ps_string(char *ins, int latin) +/* ps_string: + * internally, strings are always utf8. If chset is CHAR_LATIN1, we know + * all of the values can be represented by latin-1; if chset is + * CHAR_UTF8, we use the string as is; otherwise, we test to see if the + * string is ascii, latin-1 or non-latin, and translate to latin-l if + * possible. + */ +char *ps_string(char *ins, int chset) { char *s; char *base; @@ -267,9 +274,14 @@ char *ps_string(char *ins, int latin) static int warned; int rc; - if (latin) + switch (chset) { + case CHAR_UTF8 : + base = ins; + break; + case CHAR_LATIN1 : base = utf8ToLatin1 (ins); - else { + break; + default : switch (charsetOf (ins)) { case ASCII : base = ins; -- 2.40.0