Skip to content

Latest commit

 

History

History
86 lines (56 loc) · 1.65 KB

utf8.md

File metadata and controls

86 lines (56 loc) · 1.65 KB

Table of Content

Name

acid.utf8

Status

This library is considered production ready.

Description

This library provides basic support for UTF-8 encoding.

Synopsis

local utf8 = require('acid.utf8')

local utf8_str, err, errmsg = utf8.char({258, 0x1234})
if err ~= nil then
    ngx.say('error')
end

local code_points, err, errmsg = utf8.code_point(utf8_str)
if err ~= nil then
    ngx.say('error')
end

Methods

char

syntax: utf8_str, err, errmsg = utf8.char(code_points)

Converts each code point to its corresponding UTF-8 byte sequence and returns a string with the concatenation of all these sequences.

arguments:

  • code_points: A table contains code points.

return: A string with the concatenation of all UTF-8 sequences.

code_point

syntax: code_points, err, errmsg = utf8.code_point(utf8_str)

Returns the code points (as integers) from all characters in utf8_str.

arguments:

  • utf8_str: A utf8 encoded string.

return: A table contains code points.

Author

Renzhi (任稚) [email protected]

Copyright and License

The MIT License (MIT)

Copyright (c) 2015 Renzhi (任稚) [email protected]