📄 group__g__charset.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"><title>OCILIB (C Driver for Oracle): Charset support</title><link href="doxygen.css" rel="stylesheet" type="text/css"><link href="tabs.css" rel="stylesheet" type="text/css"></head><body><!-- Generated by Doxygen 1.5.4 --><div class="tabs"> <ul> <li><a href="index.html"><span>Main Page</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="files.html"><span>Files</span></a></li> </ul></div><h1>Charset support</h1><hr><a name="_details"></a><h2>Detailed Description</h2>OCILIB supports ANSI and Unicode charsets<p>Oracle started a real Unicode support with Oracle8i but only for user data. All SQL and PL/SQ/ statements, metadata string, database objects names, etc, ... were still only supported in ANSI.<p>With Oracle 9i, Oracle provides a full Unicode support.<p>So depending on the compile time Oracle library or the runtime loaded library, the Unicode support differs.<p>OCILIB supports :<p><ul><li>ANSI (char)</li><li>Unicode (wchar_t)</li><li>Mixed charset: ansi for metadata, Unicode for user data</li></ul><p>OCILIB uses two types of strings:<p><ul><li>mtext: for metadata, SQL strings, object attributes.</li><li>dtext: for input binds and output data</li></ul><p>mtext and dtext are declared as defines around char and wchar_t depending on the charset option<p><dl class="user" compact><dt><b>Text macro</b></dt><dd></dd></dl><ul><li>MT() macro : "meta text" -> meta data and strings passed to OCI calls</li><li>DT() macro : "data text" -> user input/output data</li></ul><p><dl class="user" compact><dt><b>Option OCI_CHARSET_ANSI</b></dt><dd></dd></dl><ul><li>dtext --> char</li><li>DT(x) --> x</li></ul><p><ul><li>mtext --> char</li><li>MT(x) --> x</li></ul><p><dl class="user" compact><dt><b>Option OCI_CHARSET_UNICODE</b></dt><dd></dd></dl><ul><li>dtext --> wchar_t</li><li>DT(x) --> L ## x</li></ul><p><ul><li>mtext --> wchar_t --MT(x) --> L ## x</li></ul><p><dl class="user" compact><dt><b>Option OCI_CHARSET_MIXED</b></dt><dd></dd></dl><ul><li>dtext --> wchar_t</li><li>DT(x) --> L ## x</li></ul><p><ul><li>mtext --> char</li><li>MT(x) --> x</li></ul><p><dl class="user" compact><dt><b>Unicode and ISO C</b></dt><dd></dd></dl>Well, ISO C:<ul><li>doesn't know anything about Unicode.</li><li>makes wide characters support tricky because the size of a wide character is not defined and is freely adaptable by implementations.</li></ul><p>OCILIB uses char/wchar_t strings for public interface and internal storage.<p>OCILIB, for Unicode builds, initialize OCI in UTF16 Unicode mode. Oracle implements this mode with a 2 bytes (fixed length) UTF16 encoding.<p>So, on systems implementing wchar_t as 2 bytes based UTF16 (e.g. Ms Windows), input strings are directly passed to Oracle and taken back from it.<p>On other systems (most of the unixes) that use UTF32 as encoding (4 bytes based wchar_t), OCILIB uses:<ul><li>temporary buffers to pass string to OCI for metadata strings</li><li>buffer expansion from UTF16 to UTF32 for user data string:<ul><li>allocation based on sizeof(wchar_t)</li><li>data filling based on sizeof(short) -> (UTF16 2 bytes)</li><li>data expansion to sizeof(wchar_t).</li></ul></li></ul><p>The buffer expansion is done inplace and has the advantage of not requiring extra buffer. That reduces the cost of the Unicode/ISO C handling overhead on Unixes.<p><dl class="user" compact><dt><b>Charset mapping macros</b></dt><dd></dd></dl>OCILIB main header file provides macro around most common string functions of the C standard library.<p>Theses macros are based on the model:<p><ul><li>mtsxxx() for mtext * typed strings</li><li>dtsxxx() for dtext * typed strings</li></ul><p>xxx is the standard C library string function name without the character type prefix (str/wcs).<p>List of available macros:<ul><li>mtsdup, dtsdup</li><li>mtscpy, dtscpy</li><li>mtsncpy, dtsncpy</li><li>mtscat, dtscat</li><li>mtsncat, dtsncat</li><li>mtslen, dtslen</li><li>mtscmp, dtscmp</li><li>mtscasecmp, dtscasecmp</li><li>mtsprintf, dtsprintf</li><li>mtstol, dtstol </li></ul><p><table border="0" cellpadding="0" cellspacing="0"><tr><td></td></tr></table><hr size="1"><address style="text-align: right;"><small>Generated on Sat Apr 18 01:13:12 2009 for OCILIB (C Driver for Oracle) by <a href="http://www.doxygen.org/index.html"><img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.4 </small></address></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -