Vely logo Empower C
install  tutorials  examples
documentation  license  about

12.1.0 released on Sep 19, 2022



Convert JSON text to UTF8 string.


json-utf8 <text> \
    [ status [ define ] <status> ] \
    [ error-text [ define ] <error text> ]


json-utf8 will convert JSON string value <text> to UTF8. <text> itself will hold the resulting UTF8 string. If you don't wish <text> to be modified, make a copy of it first (see copy-string). See utf8-json for the reverse conversion and data standards information.

You can obtain the optional <status> in "status" clause, which can be created with optional "define". <status> is VV_OKAY if successful, or VV_ERR_UTF8 if there was an error, in which case optional <error text> in "error-text" clause (which can be created with optional "define") will contain the error message.


// JSON Unicode value to encode to UTF8
char txt[] = "\u0459\\\"Doc\\\"\\n\\t\\b\\f\\r\\t\\u21d7\\u21d8\\t\\u25b7\\u25ee\\uD834\\uDD1E\\u13eb\\u2ca0\\u0448\\n\\/\\\"()\\t";

// Convert to UTF8 
json-utf8 txt status define txt_status error-text define txt_error

// Expected UTF8 result
char utf8[] = \"Doc\"\n\t\b\f\r\t⇗⇘\t▷◮𝄞ᏫⲠш\n/\"()\t";

// Make sure conversion was successful
if (strcmp (utf8, txt) || txt_status != VV_OKAY || txt_error[0] != 0) {
    @Error in converting JSON string to UTF8


UTF8 ( json-utf8   utf8-json  )  SEE ALL (documentation)

Copyright (c) 2022 DaSoftver LLC. Vely is a trademark of Dasoftver LLC. The software and information herein are provided "AS IS" and without any warranties or guarantees of any kind. Icons copyright Paweł Kuna licensed under MIT. This web page is licensed under CC-BY-SA-4.0.