Synchronet now requires the libarchive development package (e.g. libarchive-dev on Debian-based Linux distros, for more info) to build successfully.

Commit f3e14e0d authored by rswindell's avatar rswindell

New global function: utf8_width()

- returns the fixed printed-width of the specified UTF-8 encoded string
parent 5a1e7f43
......@@ -4159,6 +4159,32 @@ js_utf8_decode(JSContext *cx, uintN argc, jsval *arglist)
return JS_TRUE;
static JSBool
js_utf8_width(JSContext *cx, uintN argc, jsval *arglist)
jsval *argv=JS_ARGV(cx, arglist);
char* str = NULL;
jsrefcount rc;
JS_SET_RVAL(cx, arglist, JSVAL_VOID);
if(argc==0 || JSVAL_IS_VOID(argv[0]))
return JS_TRUE;
JSVALUE_TO_MSTRING(cx, argv[0], str, NULL);
return JS_TRUE;
size_t width = utf8_str_total_width(str);
JS_SET_RVAL(cx, arglist, INT_TO_JSVAL(width));
return JS_TRUE;
#if 0
static JSBool
......@@ -4551,6 +4577,10 @@ static jsSyncMethodSpec js_global_functions[] = {
,JSDOCSTR("returns CP437 representation of UTF-8 encoded text string or <i>null</i> on error (invalid UTF-8)")
{"utf8_width", js_utf8_width, 1, JSTYPE_NUMBER, JSDOCSTR("text")
,JSDOCSTR("returns the fixed printed-width of the specified UTF-8 string")
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment