NaviServer - programmable web server
4.99  5.0

[ Main Table Of Contents | Table Of Contents | Keyword Index ]

ns_valid_utf8(n) 4.99.30 naviserver "NaviServer Built-in Commands"

Name

ns_valid_utf8 - Check whether the provided byte-array contains a valid UTF-8 byte sequence

Table Of Contents

Synopsis

Description

COMMANDS

ns_valid_utf8 string ?varname?

This function checks whether the provided argument (a Tcl byte-array) contains a valid UTF-8 code). The function returns a boolean result. When the optional varname is specified, a variable with this name is set in failure cases to the invalid part of the input string.

Note that this function only makes sense when applied on binary data, typically read from a socket or a file.

 % ns_valid_utf8 motörhead
 1
 
 % ns_valid_utf8 "foo\x85"
 0
 
 % ns_valid_utf8 mot\x85rhead errorString
 0
 % set errorString
 mot|\x85r|...

Keywords

encoding, global built-in, i18n, parse, utf-8