aboutsummaryrefslogblamecommitdiffstats
path: root/doc/api-documentation/html/latin1utf16_8cpp-source.html
blob: 39a4173db69be24b0dc84e40eb13fff2660384e6 (plain) (tree)





































































































































                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>latin1utf16.cpp Source File</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.2.15 -->
<center>
<a class="qindex" href="index.html">Main Page</a> &nbsp; <a class="qindex" href="namespaces.html">Namespace List</a> &nbsp; <a class="qindex" href="hierarchy.html">Class Hierarchy</a> &nbsp; <a class="qindex" href="classes.html">Alphabetical List</a> &nbsp; <a class="qindex" href="annotated.html">Compound List</a> &nbsp; <a class="qindex" href="files.html">File List</a> &nbsp; <a class="qindex" href="functions.html">Compound Members</a> &nbsp; </center>
<hr><h1>latin1utf16.cpp</h1><div class="fragment"><pre>00001 <font class="comment">/******************************************************************************</font>
00002 <font class="comment"> *</font>
00003 <font class="comment"> * Latin1UTF16 -        SWFilter decendant to convert a Latin-1 character to UTF-16</font>
00004 <font class="comment"> *</font>
00005 <font class="comment"> */</font>
00006 
00007 
00008 <font class="preprocessor">#include &lt;stdlib.h&gt;</font>
00009 <font class="preprocessor">#include &lt;stdio.h&gt;</font>
00010 <font class="preprocessor">#include &lt;latin1utf16.h&gt;</font>
00011 
00012 Latin1UTF16::Latin1UTF16() {
00013 }
00014 
00015 
00016 <font class="keywordtype">char</font> Latin1UTF16::ProcessText(<font class="keywordtype">char</font> *text, <font class="keywordtype">int</font> maxlen, <font class="keyword">const</font> <a class="code" href="class_s_w_key.html">SWKey</a> *key, <font class="keyword">const</font> <a class="code" href="class_s_w_module.html">SWModule</a> *module)
00017 {
00018     <font class="keywordtype">unsigned</font> <font class="keywordtype">char</font> *from;
00019     <font class="keywordtype">unsigned</font> <font class="keywordtype">short</font> *to;
00020     <font class="keywordtype">int</font> len;
00021     
00022     len = strlen(text) + 1;                                             <font class="comment">// shift string to right of buffer</font>
00023     <font class="keywordflow">if</font> (len &lt; maxlen) {
00024       memmove(&amp;text[maxlen - len], text, len);
00025       from = (<font class="keywordtype">unsigned</font> <font class="keywordtype">char</font>*)&amp;text[maxlen - len];
00026     }
00027     <font class="keywordflow">else</font>        
00028       from = (<font class="keywordtype">unsigned</font> <font class="keywordtype">char</font>*)text;
00029     <font class="comment">// -------------------------------</font>
00030     
00031     <font class="keywordflow">for</font> (to = (<font class="keywordtype">unsigned</font> <font class="keywordtype">short</font>*)text; *from; from++) {
00032         <font class="keywordflow">switch</font> (*from) {
00033         <font class="keywordflow">case</font> 0x80: <font class="comment">// '€'</font>
00034                 *to++ = 0x20AC;
00035                 <font class="keywordflow">break</font>;
00036         <font class="keywordflow">case</font> 0x82: <font class="comment">// '‚'</font>
00037                 *to++ = 0x201A;
00038                 <font class="keywordflow">break</font>;
00039         <font class="keywordflow">case</font> 0x83: <font class="comment">// 'ƒ'</font>
00040                 *to++ = 0x0192;
00041                 <font class="keywordflow">break</font>;
00042         <font class="keywordflow">case</font> 0x84: <font class="comment">// '„'</font>
00043                 *to++ = 0x201E;
00044                 <font class="keywordflow">break</font>;
00045         <font class="keywordflow">case</font> 0x85: <font class="comment">// '…'</font>
00046                 *to++ = 0x2026;
00047                 <font class="keywordflow">break</font>;
00048         <font class="keywordflow">case</font> 0x86: <font class="comment">// '†'</font>
00049                 *to++ = 0x2020;
00050                 <font class="keywordflow">break</font>;
00051         <font class="keywordflow">case</font> 0x87: <font class="comment">// '‡'</font>
00052                 *to++ = 0x2021;
00053                 <font class="keywordflow">break</font>;
00054         <font class="keywordflow">case</font> 0x88: <font class="comment">// 'ˆ'</font>
00055                 *to++ = 0x02C6;
00056                 <font class="keywordflow">break</font>;
00057         <font class="keywordflow">case</font> 0x89: <font class="comment">// '‰'</font>
00058                 *to++ = 0x2030;
00059                 <font class="keywordflow">break</font>;
00060         <font class="keywordflow">case</font> 0x8A: <font class="comment">// 'Š'</font>
00061                 *to++ = 0x0160;
00062                 <font class="keywordflow">break</font>;
00063         <font class="keywordflow">case</font> 0x8B: <font class="comment">// '‹'</font>
00064                 *to++ = 0x2039;
00065                 <font class="keywordflow">break</font>;
00066         <font class="keywordflow">case</font> 0x8C: <font class="comment">// 'Œ'</font>
00067                 *to++ = 0x0152;
00068                 <font class="keywordflow">break</font>;
00069         <font class="keywordflow">case</font> 0x8E: <font class="comment">// 'Ž'</font>
00070                 *to++ = 0x017D;
00071                 <font class="keywordflow">break</font>;
00072         <font class="keywordflow">case</font> 0x91: <font class="comment">// '‘'</font>
00073                 *to++ = 0x2018;
00074                 <font class="keywordflow">break</font>;
00075         <font class="keywordflow">case</font> 0x92: <font class="comment">// '’'</font>
00076                 *to++ = 0x2019;
00077                 <font class="keywordflow">break</font>;
00078         <font class="keywordflow">case</font> 0x93: <font class="comment">// '“'</font>
00079                 *to++ = 0x201C;
00080                 <font class="keywordflow">break</font>;
00081         <font class="keywordflow">case</font> 0x94: <font class="comment">// '”'</font>
00082                 *to++ = 0x201D;
00083                 <font class="keywordflow">break</font>;
00084         <font class="keywordflow">case</font> 0x95: <font class="comment">// '•'</font>
00085                 *to++ = 0x2022;
00086                 <font class="keywordflow">break</font>;
00087         <font class="keywordflow">case</font> 0x96: <font class="comment">// '–'</font>
00088                 *to++ = 0x2013;
00089                 <font class="keywordflow">break</font>;
00090         <font class="keywordflow">case</font> 0x97: <font class="comment">// '—'</font>
00091                 *to++ = 0x2014;
00092                 <font class="keywordflow">break</font>;
00093         <font class="keywordflow">case</font> 0x98: <font class="comment">// '˜'</font>
00094                 *to++ = 0x02DC;
00095                 <font class="keywordflow">break</font>;
00096         <font class="keywordflow">case</font> 0x99: <font class="comment">// '™'</font>
00097                 *to++ = 0x2122;
00098                 <font class="keywordflow">break</font>;
00099         <font class="keywordflow">case</font> 0x9A: <font class="comment">// 'š'</font>
00100                 *to++ = 0x0161;
00101                 <font class="keywordflow">break</font>;
00102         <font class="keywordflow">case</font> 0x9B: <font class="comment">// '›'</font>
00103                 *to++ = 0x203A;
00104                 <font class="keywordflow">break</font>;
00105         <font class="keywordflow">case</font> 0x9C: <font class="comment">// 'œ'</font>
00106                 *to++ = 0x0153;
00107                 <font class="keywordflow">break</font>;
00108         <font class="keywordflow">case</font> 0x9E: <font class="comment">// 'ž'</font>
00109                 *to++ = 0x017E;
00110                 <font class="keywordflow">break</font>;
00111         <font class="keywordflow">case</font> 0x9F: <font class="comment">// 'Ÿ'</font>
00112                 *to++ = 0x0178;
00113                 <font class="keywordflow">break</font>;
00114         <font class="keywordflow">default</font>:
00115                *to++ = (<font class="keywordtype">unsigned</font> <font class="keywordtype">short</font>)*from;
00116         }
00117     }
00118     *to = 0;
00119     <font class="keywordflow">return</font> 0;
00120 }
</pre></div><hr><address align="right"><small>Generated on Thu Jun 20 22:12:59 2002 for The Sword Project by
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border=0 
width=110 height=53></a>1.2.15 </small></address>
</body>
</html>