akfavatar.utf8(3)                                            akfavatar.utf8(3)



NNAAMMEE
       akfavatar.utf8 - module for UTF-8 support in Lua-AKFAvatar

SSYYNNOOPPSSIISS
       local utf8 = require "akfavatar.utf8"

DDEESSCCRRIIPPTTIIOONN
       This  module  defines  functions for UTF-8 strings.  Many functions are
       replacements to the functions in Lua's string lirbrary.

       UTF-8 is a character encoding for Unicode.  A character can be  encoded
       with  one  to  four bytes.  That's why it needs special handling.  Most
       functions in the default string library of Lua can only  handle  encod‐
       ings with a single byte per character.

       uuttff88..lleenn((_s_t_r_i_n_g))
              Counts the number of characters in an UTF-8 encoded _s_t_r_i_n_g.
              NNoottee:  Control  characters and invisible characters are counted,
              too.

       uuttff88..ssuubb((_s_t_r_i_n_g_, _s_t_a_r_t_c_h_a_r _[_,_e_n_d_c_h_a_r_]))
              Like string.sub, but for UTF-8 strings.

              Returns a substring from _s_t_a_r_t_c_h_a_r to _e_n_d_c_h_a_r.  If _s_t_a_r_t_c_h_a_r  or
              _e_n_d_c_h_a_r  are negative, then they are counted from the end of the
              string.
              So, utf8.sub(s, 1, 3) returns  the  first  3  characters,  while
              utf8.sub(s, -3) returns the last 3 characters.

       uuttff88..cchhaarr((_._._.))
              Like ssttrriinngg..cchhaarr but accepts higher numbers and returns an UTF-8
              encoded string.

       uuttff88..ccooddeeppooiinntt((_s_t_r_i_n_g))
              Return the codepoint of the first character of the given _s_t_r_i_n_g.
              Returns _n_i_l on error (but that's not a real validity check).

       uuttff88..ccooddeeppooiinnttss((_s_t_r_i_n_g _[_,_s_t_a_r_t_c_h_a_r _[_,_e_n_d_c_h_a_r_]_]))
              Like ssttrriinngg..bbyyttee.
              Returns the unicode numbers of the characters from _s_t_a_r_t_c_h_a_r  to
              _e_n_d_c_h_a_r.
              If  you  only  need  the  first  character, use uuttff88..ccooddeeppooiinntt(())
              instead.

       uuttff88..cchhaarraacctteerrss((_s_t_r_i_n_g))
              Iterator for the characters of an UTF-8 string.
              A character may be a single- or multi-byte string.

              Use like this:
                for c in utf8.characters(line) do print(utf8.codepoint(c)) end

       uuttff88..rreevveerrssee((_s_t_r_i_n_g))
              Reverses an UTF-8 encoded _s_t_r_i_n_g.
              NNoottee: combining characters are still problematic.

       uuttff88..rreepp((_s_t_r_i_n_g_, _n))
              Returns the _s_t_r_i_n_g repeated _n times.  It's simply an  alias  for
              ssttrriinngg..rreepp(()).

       uuttff88..uunnddeerrlliinneedd((_s_t_r_i_n_g))
              Returns the _s_t_r_i_n_g underlined (overstrike technique).

       uuttff88..bboolldd((_s_t_r_i_n_g))
              Returns the _s_t_r_i_n_g in boldface (overstrike technique).

       uuttff88..bboomm
              Byte Order Mark.
              Not really needed for UTF8, but sometimes used as signature.

       uuttff88..cchheecckk__bboomm((_s_t_r_i_n_g))
              Check, if the _s_t_r_i_n_g starts with a UTF8-BOM.

       uuttff88..cchheecckk((_s_t_r_i_n_g))
              Check if the _s_t_r_i_n_g is an UTF-8 string.
              It's  just  for  checking  if it is UTF-8 or not, not a validity
              check.
              NNoottee: plain ASCII is also valid UTF-8.

       uuttff88..cchheecckk__uunniiccooddee((_s_t_r_i_n_g))
              Checks text for unicode encodings.
              Returns either of "UTF-8",  "UTF-16BE",  UTF-16LE",  "UTF-32BE",
              "UTF-32LE" or _n_i_l if it cannot be detected.

       uuttff88..ffrroomm__nnccrr((_s_t_r_i_n_g))
              Replaces  numeric  character references (NCR) with UTF-8 charac‐
              ters.
              For example "&#8364;" (decimal) or "&#x20AC;" (hexadecimal)  for
              the Euro currency sign.

       uuttff88..ttoo__nnccrr((_s_t_r_i_n_g))
              Replaces non-ASCII characters with numeric character references.
              The result is a plain ASCII string, but encoded.

       uuttff88..ffrroomm__llaattiinn11((_s_t_r_i_n_g))
              Converts a _s_t_r_i_n_g from Latin-1 (ISO-8859-1) to UTF-8.

       uuttff88..ttoo__llaattiinn11((_s_t_r_i_n_g _[_,_r_e_p_l_a_c_e_m_e_n_t_]))
              Converts an UTF-8 _s_t_r_i_n_g into Latin-1 (ISO-8859-1).   Characters
              which  cannot  be  converted  are  replaced with the _r_e_p_l_a_c_e_m_e_n_t
              string if given, or they are replaced with "\x1A".

SSEEEE AALLSSOO
       lluuaa--aakkffaavvaattaarr(1) lluuaa(1) lluuaa--aakkffaavvaattaarr--rreeff(3) aakkffaavvaattaarr--ggrraapphhiicc(3) aakkffaa‐‐
       vvaattaarr--tteerrmm(3)



AKFAvatar                         2012-07-22                 akfavatar.utf8(3)
