⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ug_ch5c.htm

📁 db.* (pronounced dee-be star) is an advanced, high performance, small footprint embedded database fo
💻 HTM
📖 第 1 页 / 共 4 页
字号:
<td width="18%" valign="top"><p><font size="2"><b>z,z,0,Z</b></font></p></td><td width="82%" valign="top"><p><font size="2"><b>bb5</b></font></p></td></tr><tr><td width="18%" valign="top">&nbsp;</td><td width="82%" valign="top"><p><font size="2"><b>aB6</b></font></p></td></tr><tr><td width="18%" valign="top">&nbsp;</td><td width="82%" valign="top"><p><font size="2"><b>Ab7</b></font></p></td></tr><tr><td width="18%" valign="top">&nbsp;</td><td width="82%" valign="top"><p><font size="2"><b>BB8</b></font></p></td></tr></table><p><font size="2">The left column below shows how this data wouldbe sorted. The right column shows the internal representation usedduring the sort.</font></p><table cellspacing="0" border="0" cellpadding="7" width="450"><tr><td width="19%" valign="top"><p><font size="2"><b>AA3</b></font></p></td><td width="81%" valign="top"><p><font size="2"><b>AA3</b></font></p></td></tr><tr><td width="19%" valign="top"><p><font size="2"><b>aa4</b></font></p></td><td width="81%" valign="top"><p><font size="2"><b>AA4</b></font></p></td></tr><tr><td width="19%" valign="top"><p><font size="2"><b>ab1</b></font></p></td><td width="81%" valign="top"><p><font size="2"><b>AB1</b></font></p></td></tr><tr><td width="19%" valign="top"><p><font size="2"><b>AB2</b></font></p></td><td width="81%" valign="top"><p><font size="2"><b>AB2</b></font></p></td></tr><tr><td width="19%" valign="top"><p><font size="2"><b>aB6</b></font></p></td><td width="81%" valign="top"><p><font size="2"><b>AB6</b></font></p></td></tr><tr><td width="19%" valign="top"><p><font size="2"><b>Ab7</b></font></p></td><td width="81%" valign="top"><p><font size="2"><b>AB7</b></font></p></td></tr><tr><td width="19%" valign="top"><p><font size="2"><b>bb5</b></font></p></td><td width="81%" valign="top"><p><font size="2"><b>BB5</b></font></p></td></tr><tr><td width="19%" valign="top"><p><font size="2"><b>BB8</b></font></p></td><td width="81%" valign="top"><p><font size="2"><b>BB8</b></font></p></td></tr></table><p><font size="2">Note that case in the original data is intermixedafter the sorting. Because of the zero subsort value, if we used<b>d_recwrite</b> to change the <b>bb5</b> to <b>BB5</b>,<b><i>db.*</i></b> would not write the change to disk since,according to the country table, the data did not change. Note thatthis mapping of the lowercase letters to the uppercase letters witha subsort value of zero is exactly what <b>ignorecase</b>(explained later in this section) does in the countrytable.</font></p><p>Suppose we use the same data with the same country table but wechange all the subsort values to one as listed below,</p><table cellspacing="0" border="0" cellpadding="7" width="450"><tr><td width="19%" valign="top"><p><font size="2"><b>a,a,1,A</b></font></p></td><td width="81%" valign="top"><p><font size="2"><b>ab1</b></font></p></td></tr><tr><td width="19%" valign="top"><p><font size="2"><b>b,b,1,B</b></font></p></td><td width="81%" valign="top"><p><font size="2"><b>AB2</b></font></p></td></tr><tr><td width="19%" valign="top"><p><font size="2"><b>c,c,1,C</b></font></p></td><td width="81%" valign="top"><p><font size="2"><b>AA3</b></font></p></td></tr><tr><td width="19%" valign="top"><p><font size="2"><b>...</b></font></p></td><td width="81%" valign="top"><p><font size="2"><b>aa4</b></font></p></td></tr><tr><td width="19%" valign="top"><p><font size="2"><b>z,z,1,Z</b></font></p></td><td width="81%" valign="top"><p><font size="2"><b>bb5</b></font></p></td></tr><tr><td width="19%" valign="top">&nbsp;</td><td width="81%" valign="top"><p><font size="2"><b>aB6</b></font></p></td></tr><tr><td width="19%" valign="top">&nbsp;</td><td width="81%" valign="top"><p><font size="2"><b>Ab7</b></font></p></td></tr><tr><td width="19%" valign="top">&nbsp;</td><td width="81%" valign="top"><p><font size="2"><b>BB8</b></font></p></td></tr></table><p><font size="2">The sorting sequence will be changed from thenormal ASCII ordering below</font></p><p><b>A B C ... Z ... a b c ... z</b></p><p>to the new ordering of:</p><p><b>A a B b C c ... Z z</b></p><p>The left column below shows how the above data will be sorted.The right column shows the internal representation used during thesort.</p><table cellspacing="0" border="0" cellpadding="7" width="450"><tr><td width="19%" valign="top"><p><font size="2"><b>AA3</b></font></p></td><td width="81%" valign="top"><p><font size="2"><b>A A 3</b></font></p></td></tr><tr><td width="19%" valign="top"><p><font size="2"><b>AB2</b></font></p></td><td width="81%" valign="top"><p><font size="2"><b>A B 2</b></font></p></td></tr><tr><td width="19%" valign="top"><p><font size="2"><b>Ab7</b></font></p></td><td width="81%" valign="top"><p><font size="2"><b>A B'7</b></font></p></td></tr><tr><td width="19%" valign="top"><p><font size="2"><b>aa4</b></font></p></td><td width="81%" valign="top"><p><font size="2"><b>A'A'4</b></font></p></td></tr><tr><td width="19%" valign="top"><p><font size="2"><b>aB6</b></font></p></td><td width="81%" valign="top"><p><font size="2"><b>A'B 6</b></font></p></td></tr><tr><td width="19%" valign="top"><p><font size="2"><b>ab1</b></font></p></td><td width="81%" valign="top"><p><font size="2"><b>A'B'1</b></font></p></td></tr><tr><td width="19%" valign="top"><p><font size="2"><b>BB8</b></font></p></td><td width="81%" valign="top"><p><font size="2"><b>B B 8</b></font></p></td></tr><tr><td width="19%" valign="top"><p><font size="2"><b>bb5</b></font></p></td><td width="81%" valign="top"><p><font size="2"><b>B'B'5</b></font></p></td></tr></table><p><font size="2">Since the subsort value of one means that theinput characters are not identical, <b>bb5</b> could be easilychanged to <b>BB5</b> because <b><i>db.*</i></b> would see the<b>bb</b> and <b>BB</b> as <i>not</i> exactly the same.</font></p><p>One other point to note is that the country table processing isa one-pass lookup; it will not recursively lookup characters. Forexample,</p><p><b>d,d,0,a<br>a,a,0,A</b></p><p>maps <b>d</b> to <b>a</b> and also maps <b>a</b> to <b>A</b>.However, transitive properties do not apply, which means that<b>d</b> would not be mapped to <b>A</b>. To get <b>a</b> and<b>d</b> to be sorted as the same character(s), the exact sort-asstring must be used for both as shown below:</p><p><b>d,d,X,A<br>a,a,X,A</b></p><p>An additional country table directive may appear as the firstline in <b>db.star.ctb</b>. The first line may say<b>ignorecase</b>, which will cause all lowercase letters <b>(a</b>- <b>z)</b> to have their <b>sort-as</b> characters changed totheir uppercase counterparts (<b>A</b> - <b>Z</b>) using a subsortvalue of zero. Sorting will ignore the case of the letters, but thedisplay of the characters will not be changed. If the<b>ignorecase</b> option is not used, it is necessary to specifyall of the sort-as characters in uppercase to get the sameeffect.</p><p>A possible German country table is shown below:</p><p><b>&Auml;,&Auml;,0,AE<br>&auml;,&auml;,0,ae<br>&Uuml;,&Uuml;,0,UE<br>&uuml;,&uuml;,0,ue<br>&Ouml;,&Ouml;,0,OE<br>&ouml;,&ouml;,0,oe<br>&szlig;,&szlig;,0,ss</b></p><p>Case insensitivity for the same data would be indicated asfollows:</p><p><b>ignorecase<br>&Auml;,&Auml;,0,AE<br>&auml;,&auml;,0,AE<br>&Uuml;,&Uuml;,0,UE<br>&uuml;,&uuml;,0,UE<br>&Ouml;,&Ouml;,0,OE<br>&ouml;,&ouml;,0,OE<br>&szlig;,&szlig;,0,SS</b></p><p>A an example, given the case-sensitive, German table above, thestring "&Auml;lan" would be sorted as if it was the string"AElan".</p><p>Note: The country table file is a binary file that just happensto contain only text data. Usually the country table file will becreated though the use of a text editor. However, some text editorsput end-of-file (EOF) markers (ASCII 26) at the end of files theycreate. It is important to ensure your editor does not do this asit will cause problems during the interpretation of the file; theEOF marker will be treated as part of the string being read fromthe file.</p><p>The functionality of the country table can be createdprogrammatically using the <b>d_mapchar</b> and <b>d_on_opt</b>functions (see the function descriptions in the <b><i>db.*</i>Reference Manual</b>). The following calls can be made beforeopening the database to create the case-sensitive German characterset mapping (note the change in the parameter ordering):</p><pre><font color="#0000FF">d_mapchar( '&Auml;', '&Auml;', "AE", 0, task );d_mapchar( '&auml;', '&auml;', "ae", 0, task );d_mapchar( '&Uuml;', '&Uuml;', "UE", 0, task );d_mapchar( '&uuml;', '&uuml;', "ue", 0, task );d_mapchar( '&Ouml;', '&Ouml;', "OE", 0, task );d_mapchar( '&ouml;', '&ouml;', "oe", 0, task );d_mapchar( '&szlig;', '&szlig;', "ss", 0, task );</font></pre><p><font size="2">This is the case insensitive option:</font></p><pre><font color="#0000FF">d_on_opt( IGNORECASE );d_mapchar( '&Auml;', '&Auml;', "AE", 0, task );d_mapchar( '&auml;', '&auml;', "AE", 0, task );d_mapchar( '&Uuml;', '&Uuml;', "UE", 0, task );d_mapchar( '&uuml;', '&uuml;', "UE", 0, task );d_mapchar( '&Ouml;', '&Ouml;', "OE", 0, task );d_mapchar( '&ouml;', '&ouml;', "OE", 0, task );d_mapchar( '&szlig;', '&szlig;', "SS", 0, task );</font></pre><p><font size="2">The use of the functions eliminates the need forthe country table file, but there are big disadvantages to usingthe functions instead of the country table file. The country tablefile is used by all <b><i>db.*</i></b> utilities and applicationsthat call <b>d_open</b>. Hence if a database is built by anapplication using the above function calls, and a utility such as<b>ida</b> is used on the database, it may find the keys in anorder other than expected. Worse yet, if it adds keys to thedatabase, it will do so with a different collating sequence, whichwill cause the key files to become corrupted.</font></p><p><font size="2">The safest way to use international characters isto define them in a country table that will always be used when thedatabase is used. If the function calls are used in applicationcode (to eliminate the extra file), it will still be necessary touse a country table file when the utilities are used on the samedatabase. Alternatively, the <b>ignorecase</b> and CTBPATHinformation can be put into the <b>db.star.ini</b> file.</font></p><p><a href="UG_Ch6.htm">Next Page</a></p></body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -