<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> <meta http-equiv="X-UA-Compatible" content="IE=9"/> <meta name="generator" content="Doxygen 1.8.8"/> <title>ZVBI Library: Character set conversion functions</title> <link href="tabs.css" rel="stylesheet" type="text/css"/> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript" src="dynsections.js"></script> <link href="doxygen.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="top"><!-- do not remove this div, it is closed by doxygen! --> <div id="titlearea"> <table cellspacing="0" cellpadding="0"> <tbody> <tr style="height: 56px;"> <td style="padding-left: 0.5em;"> <div id="projectname">ZVBI Library  <span id="projectnumber">0.2.35</span> </div> </td> </tr> </tbody> </table> </div> <!-- end header part --> <!-- Generated by Doxygen 1.8.8 --> <div id="navrow1" class="tabs"> <ul class="tablist"> <li><a href="index.html"><span>Main Page</span></a></li> <li><a href="pages.html"><span>Related Pages</span></a></li> <li><a href="modules.html"><span>Modules</span></a></li> <li><a href="annotated.html"><span>Data Structures</span></a></li> <li><a href="examples.html"><span>Examples</span></a></li> </ul> </div> </div><!-- top --> <div class="header"> <div class="summary"> <a href="#define-members">Macros</a> | <a href="#func-members">Functions</a> </div> <div class="headertitle"> <div class="title">Character set conversion functions<div class="ingroups"><a class="el" href="group__LowDec.html">Low Level Decoding</a></div></div> </div> </div><!--header--> <div class="contents"> <p>Helper functions to convert between Closed Caption, Teletext, Unicode and the locale character set. <a href="#details">More...</a></p> <table class="memberdecls"> <tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="define-members"></a> Macros</h2></td></tr> <tr class="memitem:gaca955407d450ed6065f2e219c9f879e6"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="gaca955407d450ed6065f2e219c9f879e6"></a> #define </td><td class="memItemRight" valign="bottom"><b>VBI_NUL_TERMINATED</b>   -1</td></tr> <tr class="separator:gaca955407d450ed6065f2e219c9f879e6"><td class="memSeparator" colspan="2"> </td></tr> </table><table class="memberdecls"> <tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a> Functions</h2></td></tr> <tr class="memitem:ga80b5eb70475e34a24733e5ccaa3e9b9f"><td class="memItemLeft" align="right" valign="top">unsigned long </td><td class="memItemRight" valign="bottom"><a class="el" href="group__Conv.html#ga80b5eb70475e34a24733e5ccaa3e9b9f">vbi_strlen_ucs2</a> (const uint16_t *src)</td></tr> <tr class="separator:ga80b5eb70475e34a24733e5ccaa3e9b9f"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:gac19f92bda7624f3d096ee58b388840fc"><td class="memItemLeft" align="right" valign="top">char * </td><td class="memItemRight" valign="bottom"><a class="el" href="group__Conv.html#gac19f92bda7624f3d096ee58b388840fc">vbi_strndup_iconv_ucs2</a> (const char *dst_codeset, const uint16_t *src, long src_length, int repl_char)</td></tr> <tr class="separator:gac19f92bda7624f3d096ee58b388840fc"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:gab360448d13ec1cd3c4a7a4babb07243f"><td class="memItemLeft" align="right" valign="top">char * </td><td class="memItemRight" valign="bottom"><a class="el" href="group__Conv.html#gab360448d13ec1cd3c4a7a4babb07243f">vbi_strndup_iconv</a> (const char *dst_codeset, const char *src_codeset, const char *src, unsigned long src_size, int repl_char)</td></tr> <tr class="separator:gab360448d13ec1cd3c4a7a4babb07243f"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:gaac3f3b17d6fe089ea66541f8d14255e6"><td class="memItemLeft" align="right" valign="top">vbi_bool </td><td class="memItemRight" valign="bottom"><a class="el" href="group__Conv.html#gaac3f3b17d6fe089ea66541f8d14255e6">vbi_fputs_iconv</a> (FILE *fp, const char *dst_codeset, const char *src_codeset, const char *src, unsigned long src_size, int repl_char)</td></tr> <tr class="separator:gaac3f3b17d6fe089ea66541f8d14255e6"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:gaeffd10bd2ffee99cd428b2268c380f4b"><td class="memItemLeft" align="right" valign="top">vbi_bool </td><td class="memItemRight" valign="bottom"><a class="el" href="group__Conv.html#gaeffd10bd2ffee99cd428b2268c380f4b">vbi_fputs_iconv_ucs2</a> (FILE *fp, const char *dst_codeset, const uint16_t *src, long src_length, int repl_char)</td></tr> <tr class="separator:gaeffd10bd2ffee99cd428b2268c380f4b"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:ga69e68f14e65c01622db558df3e6a11f6"><td class="memItemLeft" align="right" valign="top">const char * </td><td class="memItemRight" valign="bottom"><a class="el" href="group__Conv.html#ga69e68f14e65c01622db558df3e6a11f6">vbi_locale_codeset</a> (void)</td></tr> <tr class="separator:ga69e68f14e65c01622db558df3e6a11f6"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:gaed83a362d4a7e408f5c42a82fa02e356"><td class="memItemLeft" align="right" valign="top">char * </td><td class="memItemRight" valign="bottom"><a class="el" href="group__Conv.html#gaed83a362d4a7e408f5c42a82fa02e356">vbi_strndup_iconv_caption</a> (const char *dst_codeset, const char *src, long src_length, int repl_char) _vbi_alloc</td></tr> <tr class="separator:gaed83a362d4a7e408f5c42a82fa02e356"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:gadbe555b3d116e51d6accc7ec45fa5ef6"><td class="memItemLeft" align="right" valign="top">unsigned int </td><td class="memItemRight" valign="bottom"><a class="el" href="group__Conv.html#gadbe555b3d116e51d6accc7ec45fa5ef6">vbi_caption_unicode</a> (unsigned int c, vbi_bool to_upper)</td></tr> <tr class="separator:gadbe555b3d116e51d6accc7ec45fa5ef6"><td class="memSeparator" colspan="2"> </td></tr> </table> <a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2> <p>Helper functions to convert between Closed Caption, Teletext, Unicode and the locale character set. </p> <h2 class="groupheader">Function Documentation</h2> <a class="anchor" id="ga80b5eb70475e34a24733e5ccaa3e9b9f"></a> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">unsigned long vbi_strlen_ucs2 </td> <td>(</td> <td class="paramtype">const uint16_t * </td> <td class="paramname"><em>src</em></td><td>)</td> <td></td> </tr> </table> </div><div class="memdoc"> <dl class="params"><dt>Parameters</dt><dd> <table class="params"> <tr><td class="paramname">src</td><td>NUL-terminated UCS-2 string.</td></tr> </table> </dd> </dl> <p>Counts the characters in the string, up to and excluding the terminating NUL.</p> <dl class="section since"><dt>Since</dt><dd>0.2.23 </dd></dl> <p>Referenced by <a class="el" href="group__Conv.html#gaeffd10bd2ffee99cd428b2268c380f4b">vbi_fputs_iconv_ucs2()</a>.</p> </div> </div> <a class="anchor" id="gac19f92bda7624f3d096ee58b388840fc"></a> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">char * vbi_strndup_iconv_ucs2 </td> <td>(</td> <td class="paramtype">const char * </td> <td class="paramname"><em>dst_codeset</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">const uint16_t * </td> <td class="paramname"><em>src</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">long </td> <td class="paramname"><em>src_length</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">int </td> <td class="paramname"><em>repl_char</em> </td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td> </tr> </table> </div><div class="memdoc"> <dl class="params"><dt>Parameters</dt><dd> <table class="params"> <tr><td class="paramname">dst_codeset</td><td>Character set name for iconv() conversion, for example "ISO-8859-1". When <code>NULL</code> the default is UTF-8. </td></tr> <tr><td class="paramname">src</td><td>Source string in UCS-2 format, can be <code>NULL</code>. </td></tr> <tr><td class="paramname">src_length</td><td>Number of characters (not bytes) in the source string. Can be -1 if the string is NUL terminated. </td></tr> <tr><td class="paramname">repl_char</td><td>UCS-2 replacement for characters which are not representable in <em>dst_codeset</em>. When zero the function will fail if the source buffer contains unrepresentable characters.</td></tr> </table> </dd> </dl> <p>Converts a UCS-2 string with iconv() and writes the result with a terminating NUL character into a newly allocated buffer.</p> <dl class="section return"><dt>Returns</dt><dd>A pointer to the allocated buffer. You must free() the buffer when it is no longer needed. The function returns <code>NULL</code> when the conversion fails, when it runs out of memory or when <em>src</em> is <code>NULL</code>.</dd></dl> <dl class="section since"><dt>Since</dt><dd>0.2.23 </dd></dl> </div> </div> <a class="anchor" id="gab360448d13ec1cd3c4a7a4babb07243f"></a> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">char * vbi_strndup_iconv </td> <td>(</td> <td class="paramtype">const char * </td> <td class="paramname"><em>dst_codeset</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">const char * </td> <td class="paramname"><em>src_codeset</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">const char * </td> <td class="paramname"><em>src</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">unsigned long </td> <td class="paramname"><em>src_size</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">int </td> <td class="paramname"><em>repl_char</em> </td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td> </tr> </table> </div><div class="memdoc"> <dl class="params"><dt>Parameters</dt><dd> <table class="params"> <tr><td class="paramname">dst_codeset</td><td>Character set name for iconv() conversion, for example "ISO-8859-1". When <code>NULL</code> the default is UTF-8. </td></tr> <tr><td class="paramname">src_codeset</td><td>Character set name for iconv() conversion, for example "ISO-8859-1". When <code>NULL</code> the default is UTF-8. </td></tr> <tr><td class="paramname">src</td><td>Source buffer, can be <code>NULL</code>. </td></tr> <tr><td class="paramname">src_size</td><td>Number of bytes in the source string (excluding the terminating NUL, if any). </td></tr> <tr><td class="paramname">repl_char</td><td>UCS-2 replacement for characters which are not representable in <em>dst_codeset</em>. When zero the function will fail if the source buffer contains unrepresentable characters.</td></tr> </table> </dd> </dl> <p>Converts a string with iconv() and writes the result with a terminating NUL character into a newly allocated buffer.</p> <dl class="section return"><dt>Returns</dt><dd>A pointer to the allocated buffer. You must free() the buffer when it is no longer needed. The function returns <code>NULL</code> when the conversion fails, when it runs out of memory or when <em>src</em> is <code>NULL</code>.</dd></dl> <dl class="section since"><dt>Since</dt><dd>0.2.23 </dd></dl> <dl><dt><b>Examples: </b></dt><dd><a class="el" href="examples_2network_8c-example.html#a7">examples/network.c</a>.</dd> </dl> <p>Referenced by <a class="el" href="group__Conv.html#gaed83a362d4a7e408f5c42a82fa02e356">vbi_strndup_iconv_caption()</a>.</p> </div> </div> <a class="anchor" id="gaac3f3b17d6fe089ea66541f8d14255e6"></a> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">vbi_bool vbi_fputs_iconv </td> <td>(</td> <td class="paramtype">FILE * </td> <td class="paramname"><em>fp</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">const char * </td> <td class="paramname"><em>dst_codeset</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">const char * </td> <td class="paramname"><em>src_codeset</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">const char * </td> <td class="paramname"><em>src</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">unsigned long </td> <td class="paramname"><em>src_size</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">int </td> <td class="paramname"><em>repl_char</em> </td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td> </tr> </table> </div><div class="memdoc"> <dl class="params"><dt>Parameters</dt><dd> <table class="params"> <tr><td class="paramname">fp</td><td>Output file. </td></tr> <tr><td class="paramname">dst_codeset</td><td>Character set name for iconv() conversion, for example "ISO-8859-1". When <code>NULL</code> the default is UTF-8. </td></tr> <tr><td class="paramname">src_codeset</td><td>Character set name for iconv() conversion, for example "ISO-8859-1". When <code>NULL</code> the default is UTF-8. </td></tr> <tr><td class="paramname">src</td><td>Source buffer, can be <code>NULL</code>. </td></tr> <tr><td class="paramname">src_size</td><td>Number of bytes in the source string (excluding the terminating NUL, if any). </td></tr> <tr><td class="paramname">repl_char</td><td>UCS-2 replacement for characters which are not representable in <em>dst_codeset</em>. When zero the function will fail if the source buffer contains unrepresentable characters.</td></tr> </table> </dd> </dl> <p>Converts a string with iconv() and writes the result into the given file.</p> <dl class="section return"><dt>Returns</dt><dd>FALSE on failure.</dd></dl> <dl class="section since"><dt>Since</dt><dd>0.2.23 </dd></dl> <p>Referenced by <a class="el" href="group__Conv.html#gaeffd10bd2ffee99cd428b2268c380f4b">vbi_fputs_iconv_ucs2()</a>.</p> </div> </div> <a class="anchor" id="gaeffd10bd2ffee99cd428b2268c380f4b"></a> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">vbi_bool vbi_fputs_iconv_ucs2 </td> <td>(</td> <td class="paramtype">FILE * </td> <td class="paramname"><em>fp</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">const char * </td> <td class="paramname"><em>dst_codeset</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">const uint16_t * </td> <td class="paramname"><em>src</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">long </td> <td class="paramname"><em>src_length</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">int </td> <td class="paramname"><em>repl_char</em> </td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td> </tr> </table> </div><div class="memdoc"> <dl class="params"><dt>Parameters</dt><dd> <table class="params"> <tr><td class="paramname">fp</td><td>Output file. </td></tr> <tr><td class="paramname">dst_codeset</td><td>Character set name for iconv() conversion, for example "ISO-8859-1". When <code>NULL</code> the default is UTF-8. </td></tr> <tr><td class="paramname">src</td><td>Source string in UCS-2 format, can be <code>NULL</code>. </td></tr> <tr><td class="paramname">src_length</td><td>Number of characters (not bytes) in the source string. Can be -1 if the string is NUL terminated. </td></tr> <tr><td class="paramname">repl_char</td><td>UCS-2 replacement for characters which are not representable in <em>dst_codeset</em>. When zero the function will fail if the source buffer contains unrepresentable characters.</td></tr> </table> </dd> </dl> <p>Converts a UCS-2 string with iconv() and writes the result into the given file.</p> <dl class="section return"><dt>Returns</dt><dd>FALSE on failure.</dd></dl> <dl class="section since"><dt>Since</dt><dd>0.2.23 </dd></dl> <p>References <a class="el" href="group__Conv.html#gaac3f3b17d6fe089ea66541f8d14255e6">vbi_fputs_iconv()</a>, and <a class="el" href="group__Conv.html#ga80b5eb70475e34a24733e5ccaa3e9b9f">vbi_strlen_ucs2()</a>.</p> </div> </div> <a class="anchor" id="ga69e68f14e65c01622db558df3e6a11f6"></a> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">const char * vbi_locale_codeset </td> <td>(</td> <td class="paramtype">void </td> <td class="paramname"></td><td>)</td> <td></td> </tr> </table> </div><div class="memdoc"> <p>Returns the character encoding used by the current locale, for example "UTF-8". <code>NULL</code> if unknown.</p> <p>Note applications must call </p><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno"> 1</span> setlocale (LC_ALL, "");</div> </div><!-- fragment --><p> to use the locale specified by the environment. The default C locale uses ASCII encoding.</p> <dl class="section since"><dt>Since</dt><dd>0.2.23 </dd></dl> <dl><dt><b>Examples: </b></dt><dd><a class="el" href="examples_2network_8c-example.html#a8">examples/network.c</a>.</dd> </dl> </div> </div> <a class="anchor" id="gaed83a362d4a7e408f5c42a82fa02e356"></a> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">char* vbi_strndup_iconv_caption </td> <td>(</td> <td class="paramtype">const char * </td> <td class="paramname"><em>dst_codeset</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">const char * </td> <td class="paramname"><em>src</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">long </td> <td class="paramname"><em>src_length</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">int </td> <td class="paramname"><em>repl_char</em> </td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td> </tr> </table> </div><div class="memdoc"> <dl class="params"><dt>Parameters</dt><dd> <table class="params"> <tr><td class="paramname">dst_codeset</td><td>Character set name for iconv() conversion, for example "ISO-8859-1". When <code>NULL</code> the default is UTF-8. </td></tr> <tr><td class="paramname">src</td><td>String of Closed Caption characters, can be <code>NULL</code>. </td></tr> <tr><td class="paramname">src_length</td><td>Number of characters (= bytes) in the source string. Can be -1 if the <em>src</em> string is NUL terminated. </td></tr> <tr><td class="paramname">repl_char</td><td>UCS-2 replacement for characters which are not representable in <em>dst_codeset</em>. When zero the function will fail if the source buffer contains unrepresentable characters.</td></tr> </table> </dd> </dl> <p>Converts a string of EIA 608 Closed Caption characters to another format and stores the result with a terminating NUL in a newly allocated buffer. The function ignores parity bits and the bytes 0x00 ... 0x1F except two byte special and extended characters (e.g. music note 0x11 0x37).</p> <dl class="section see"><dt>See also</dt><dd><a class="el" href="group__Conv.html#gadbe555b3d116e51d6accc7ec45fa5ef6">vbi_caption_unicode()</a></dd></dl> <dl class="section return"><dt>Returns</dt><dd>A pointer to the allocated buffer. You must free() the buffer when it is no longer needed. The function returns <code>NULL</code> when the source buffer contains invalid two byte characters, when the conversion fails, when it runs out of memory or when <em>src</em> is <code>NULL</code>.</dd></dl> <dl class="section since"><dt>Since</dt><dd>0.2.23 </dd></dl> <p>References <a class="el" href="group__Conv.html#gab360448d13ec1cd3c4a7a4babb07243f">vbi_strndup_iconv()</a>.</p> </div> </div> <a class="anchor" id="gadbe555b3d116e51d6accc7ec45fa5ef6"></a> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">unsigned int vbi_caption_unicode </td> <td>(</td> <td class="paramtype">unsigned int </td> <td class="paramname"><em>c</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">vbi_bool </td> <td class="paramname"><em>to_upper</em> </td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td> </tr> </table> </div><div class="memdoc"> <dl class="params"><dt>Parameters</dt><dd> <table class="params"> <tr><td class="paramname">c</td><td>Character code in range 0x20 ... 0x7F, 0x1130 ... 0x113F, 0x1930 ... 0x193F, 0x1220 ... 0x123F, 0x1A20 ... 0x1A3F, 0x1320 ... 0x133F, 0x1B20 ... 0x1B3F. </td></tr> <tr><td class="paramname">to_upper</td><td>Convert the character to upper case. (In general real time caption is capitalized, but for a few accented characters older versions of the standard defined only lower case character codes. This option is available to conveniently capitalize all characters received.)</td></tr> </table> </dd> </dl> <p>Converts a Closed Caption character code to Unicode. Codes in range 0x1130 to 0x1B3F are "special characters" and "extended characters" (e.g. caption command 0x11 0x37).</p> <dl class="section see"><dt>See also</dt><dd><a class="el" href="group__Conv.html#gaed83a362d4a7e408f5c42a82fa02e356">vbi_strndup_iconv_caption()</a></dd></dl> <dl class="section return"><dt>Returns</dt><dd>Unicode value or 0 if <em>c</em> is outside the valid ranges.</dd></dl> <dl class="section since"><dt>Since</dt><dd>0.2.23 </dd></dl> </div> </div> </div><!-- contents --> <!-- start footer part --> <hr class="footer"/><address class="footer"><small> Generated on Thu Oct 16 2014 08:52:23 for ZVBI Library by  <a href="http://www.doxygen.org/index.html"> <img class="footer" src="doxygen.png" alt="doxygen"/> </a> 1.8.8 </small></address> </body> </html>