Sophie

Sophie

distrib > Fedora > 13 > x86_64 > by-pkgid > ca44e7e21c4b6cd5e0c5fdfbf12b4de7 > files > 135

libnjb-devel-2.2.6-6.fc12.x86_64.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>libnjb: /builddir/build/BUILD/libnjb-2.2.6/src/unicode.c File Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css">
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.5.9 -->
<div class="navigation" id="top">
  <div class="tabs">
    <ul>
      <li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li><a href="annotated.html"><span>Data&nbsp;Structures</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
      <li><a href="dirs.html"><span>Directories</span></a></li>
      <li><a href="examples.html"><span>Examples</span></a></li>
    </ul>
  </div>
  <div class="tabs">
    <ul>
      <li><a href="files.html"><span>File&nbsp;List</span></a></li>
      <li><a href="globals.html"><span>Globals</span></a></li>
    </ul>
  </div>
  <div class="navpath"><a class="el" href="dir_a231d544ee85f784af5e92462fb4d8ea.html">src</a>
  </div>
</div>
<div class="contents">
<h1>unicode.c File Reference</h1><code>#include &lt;stdlib.h&gt;</code><br>
<code>#include &lt;string.h&gt;</code><br>
<code>#include &lt;errno.h&gt;</code><br>
<code>#include &quot;<a class="el" href="libnjb_8h_source.html">libnjb.h</a>&quot;</code><br>
<code>#include &quot;protocol.h&quot;</code><br>
<code>#include &quot;<a class="el" href="protocol3_8h_source.html">protocol3.h</a>&quot;</code><br>
<code>#include &quot;unicode.h&quot;</code><br>
<code>#include &quot;njb_error.h&quot;</code><br>
<code>#include &quot;usb_io.h&quot;</code><br>
<code>#include &quot;ioutil.h&quot;</code><br>
<code>#include &quot;defs.h&quot;</code><br>
<code>#include &quot;base.h&quot;</code><br>
<table border="0" cellpadding="0" cellspacing="0">
<tr><td></td></tr>
<tr><td colspan="2"><br><h2>Defines</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="6789ebc0df71a8ef76bfbb4fb5f74aad"></a><!-- doxytag: member="unicode.c::MAX_STRING_LENGTH" ref="6789ebc0df71a8ef76bfbb4fb5f74aad" args="" -->
#define&nbsp;</td><td class="memItemRight" valign="bottom"><b>MAX_STRING_LENGTH</b>&nbsp;&nbsp;&nbsp;512</td></tr>

<tr><td colspan="2"><br><h2>Functions</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="unicode_8c.html#4af1a0bee89d7ee79ebb1bfb557f8e5e">njb_set_unicode</a> (int flag)</td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top">int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="unicode_8c.html#cd147761736f45b4282bebb6147c440a">ucs2strlen</a> (const unsigned char *unicstr)</td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top">char *&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="unicode_8c.html#4b1829345b6bf2af61d6dbbb1b02726b">strtoutf8</a> (const unsigned char *str)</td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top">char *&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="unicode_8c.html#767008fdd0e78d87acbc7f1ad3bf4830">utf8tostr</a> (const unsigned char *str)</td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top">char *&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="unicode_8c.html#841f6472d66d10714cb565821cdb627f">ucs2tostr</a> (const unsigned char *unicstr)</td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top">unsigned char *&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="unicode_8c.html#7a77d04f2f0563c9c74d28fca28effdd">strtoucs2</a> (const unsigned char *str)</td></tr>

<tr><td colspan="2"><br><h2>Variables</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="unicode_8c.html#60db410c9e82d9e61b1bf0be607922ed">__sub_depth</a></td></tr>

<tr><td class="memItemLeft" nowrap align="right" valign="top">int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="unicode_8c.html#c04b373ed657c74d96015d8935eb57b0">njb_unicode_flag</a> = NJB_UC_8859</td></tr>

</table>
<hr><h2>Detailed Description</h2>
This file contains general Unicode string manipulation functions. It mainly consist of functions for converting between UCS-2 (used on the devices), UTF-8 (used by several applications) and ISO 8859-1 / Codepage 1252 (fallback). <hr><h2>Function Documentation</h2>
<a class="anchor" name="4af1a0bee89d7ee79ebb1bfb557f8e5e"></a><!-- doxytag: member="unicode.c::njb_set_unicode" ref="4af1a0bee89d7ee79ebb1bfb557f8e5e" args="(int flag)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void njb_set_unicode           </td>
          <td>(</td>
          <td class="paramtype">int&nbsp;</td>
          <td class="paramname"> <em>flag</em>          </td>
          <td>&nbsp;)&nbsp;</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
This flag determines whether to use ISO 8859-1 / codepage 1252 (default) or unicode UTF-8 for ALL strings sent into and out of libnjb, for ALL sessions and devices.<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>flag</em>&nbsp;</td><td>0 for ISO 8859-1 / codepage 1252 or 1 for Unicode UTF-8. </td></tr>
  </table>
</dl>

<p>Referenced by <a class="el" href="procedure_8c_source.html#l02833">NJB_Set_Unicode()</a>.</p>

</div>
</div><p>
<a class="anchor" name="7a77d04f2f0563c9c74d28fca28effdd"></a><!-- doxytag: member="unicode.c::strtoucs2" ref="7a77d04f2f0563c9c74d28fca28effdd" args="(const unsigned char *str)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">unsigned char* strtoucs2           </td>
          <td>(</td>
          <td class="paramtype">const unsigned char *&nbsp;</td>
          <td class="paramname"> <em>str</em>          </td>
          <td>&nbsp;)&nbsp;</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Convert a simple ISO 8859-1 or a Unicode UTF8 string (depending on library Unicode flag) to a unicode UCS-2 string.<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>str</em>&nbsp;</td><td>the ISO 8859-1 or UTF-8 string to conver </td></tr>
  </table>
</dl>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>a pointer to a newly allocated UCS-2 string </dd></dl>

<p>References <a class="el" href="libnjb_8h_source.html#l00147">NJB_UC_UTF8</a>.</p>

<p>Referenced by <a class="el" href="datafile_8c_source.html#l00321">datafile_pack3()</a>, <a class="el" href="datafile_8c_source.html#l00426">new_folder_pack3()</a>, <a class="el" href="procedure_8c_source.html#l02206">NJB_Update_Playlist()</a>, <a class="el" href="songid_8c_source.html#l00233">songid_pack()</a>, <a class="el" href="songid_8c_source.html#l00449">songid_pack3()</a>, and <a class="el" href="unicode_8c_source.html#l00147">utf8tostr()</a>.</p>

</div>
</div><p>
<a class="anchor" name="4b1829345b6bf2af61d6dbbb1b02726b"></a><!-- doxytag: member="unicode.c::strtoutf8" ref="4b1829345b6bf2af61d6dbbb1b02726b" args="(const unsigned char *str)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">char* strtoutf8           </td>
          <td>(</td>
          <td class="paramtype">const unsigned char *&nbsp;</td>
          <td class="paramname"> <em>str</em>          </td>
          <td>&nbsp;)&nbsp;</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
This function converts an ordinary ISO 8859-1 string to a unicode UTF-8 string<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>str</em>&nbsp;</td><td>the ISO 8859-1 string to convert </td></tr>
  </table>
</dl>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>a newly allocated UTF-8 encoded string with the same content. Should be freed after use. </dd></dl>

<p>Referenced by <a class="el" href="datafile_8c_source.html#l00164">datafile_unpack()</a>, <a class="el" href="procedure_8c_source.html#l00697">NJB_Get_Owner_String()</a>, <a class="el" href="playlist_8c_source.html#l00056">playlist_unpack()</a>, and <a class="el" href="songid_8c_source.html#l00068">songid_unpack()</a>.</p>

</div>
</div><p>
<a class="anchor" name="cd147761736f45b4282bebb6147c440a"></a><!-- doxytag: member="unicode.c::ucs2strlen" ref="cd147761736f45b4282bebb6147c440a" args="(const unsigned char *unicstr)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int ucs2strlen           </td>
          <td>(</td>
          <td class="paramtype">const unsigned char *&nbsp;</td>
          <td class="paramname"> <em>unicstr</em>          </td>
          <td>&nbsp;)&nbsp;</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Gets the length (in characters, not bytes) of a unicode UCS-2 string, eg a string which physically is 0x00 0x41 0x00 0x00 will return a value of 1.<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>unicstr</em>&nbsp;</td><td>a UCS-2 Unicode string </td></tr>
  </table>
</dl>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>the length of the string, in number of characters. If you want to know the length in bytes, multiply this by two and add two (for zero terminator). </dd></dl>

<p>Referenced by <a class="el" href="protocol3_8c_source.html#l03749">njb3_create_playlist()</a>, <a class="el" href="protocol3_8c_source.html#l03612">njb3_update_string_frame()</a>, <a class="el" href="songid_8c_source.html#l00233">songid_pack()</a>, <a class="el" href="songid_8c_source.html#l00449">songid_pack3()</a>, and <a class="el" href="unicode_8c_source.html#l00183">ucs2tostr()</a>.</p>

</div>
</div><p>
<a class="anchor" name="841f6472d66d10714cb565821cdb627f"></a><!-- doxytag: member="unicode.c::ucs2tostr" ref="841f6472d66d10714cb565821cdb627f" args="(const unsigned char *unicstr)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">char* ucs2tostr           </td>
          <td>(</td>
          <td class="paramtype">const unsigned char *&nbsp;</td>
          <td class="paramname"> <em>unicstr</em>          </td>
          <td>&nbsp;)&nbsp;</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
Converts a Unicode UCS-2 2-byte string to a common ISO 8859-1 string quick and dirty (japanese unicodes etc, that use all 16 bits will fail miserably)<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>unicstr</em>&nbsp;</td><td>the UCS-2 unicode string to convert </td></tr>
  </table>
</dl>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>a newly allocated ISO 8859-1 string that tries to resemble the UCS-2 string </dd></dl>

<p>References <a class="el" href="libnjb_8h_source.html#l00147">NJB_UC_UTF8</a>, and <a class="el" href="unicode_8c_source.html#l00050">ucs2strlen()</a>.</p>

<p>Referenced by <a class="el" href="songid_8c_source.html#l00068">songid_unpack()</a>.</p>

</div>
</div><p>
<a class="anchor" name="767008fdd0e78d87acbc7f1ad3bf4830"></a><!-- doxytag: member="unicode.c::utf8tostr" ref="767008fdd0e78d87acbc7f1ad3bf4830" args="(const unsigned char *str)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">char* utf8tostr           </td>
          <td>(</td>
          <td class="paramtype">const unsigned char *&nbsp;</td>
          <td class="paramname"> <em>str</em>          </td>
          <td>&nbsp;)&nbsp;</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
This function approximates an ISO 8859-1 string from a UTF-8 string, leaving out untranslatable characters<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
  <table border="0" cellspacing="2" cellpadding="0">
    <tr><td valign="top"></td><td valign="top"><em>str</em>&nbsp;</td><td>the UTF-8 string to use as indata </td></tr>
  </table>
</dl>
<dl class="return" compact><dt><b>Returns:</b></dt><dd>a newly allocated ISO 8859-1 string which is as close a possible to the UTF-8 string. </dd></dl>

<p>References <a class="el" href="unicode_8c_source.html#l00255">strtoucs2()</a>.</p>

<p>Referenced by <a class="el" href="datafile_8c_source.html#l00238">datafile_pack()</a>, <a class="el" href="procedure_8c_source.html#l00746">NJB_Set_Owner_String()</a>, <a class="el" href="procedure_8c_source.html#l02206">NJB_Update_Playlist()</a>, and <a class="el" href="songid_8c_source.html#l00233">songid_pack()</a>.</p>

</div>
</div><p>
<hr><h2>Variable Documentation</h2>
<a class="anchor" name="60db410c9e82d9e61b1bf0be607922ed"></a><!-- doxytag: member="unicode.c::__sub_depth" ref="60db410c9e82d9e61b1bf0be607922ed" args="" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int <a class="el" href="usb__io_8c.html#60db410c9e82d9e61b1bf0be607922ed">__sub_depth</a>          </td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
The current subroutine depth for all of libnjb (global) 
</div>
</div><p>
<a class="anchor" name="c04b373ed657c74d96015d8935eb57b0"></a><!-- doxytag: member="unicode.c::njb_unicode_flag" ref="c04b373ed657c74d96015d8935eb57b0" args="" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int <a class="el" href="unicode_8c.html#c04b373ed657c74d96015d8935eb57b0">njb_unicode_flag</a> = NJB_UC_8859          </td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>
A flag for if unicode is used or not (global) 
</div>
</div><p>
</div>
<hr size="1"><address style="text-align: right;"><small>Generated on Sun Jul 26 17:17:29 2009 for libnjb by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.9 </small></address>
</body>
</html>