00001 /******************************************************************************* 00002 00003 @file UConverter.d 00004 00005 Copyright (c) 2004 Kris Bell 00006 00007 This software is provided 'as-is', without any express or implied 00008 warranty. In no event will the authors be held liable for damages 00009 of any kind arising from the use of this software. 00010 00011 Permission is hereby granted to anyone to use this software for any 00012 purpose, including commercial applications, and to alter it and/or 00013 redistribute it freely, subject to the following restrictions: 00014 00015 1. The origin of this software must not be misrepresented; you must 00016 not claim that you wrote the original software. If you use this 00017 software in a product, an acknowledgment within documentation of 00018 said product would be appreciated but is not required. 00019 00020 2. Altered source versions must be plainly marked as such, and must 00021 not be misrepresented as being the original software. 00022 00023 3. This notice may not be removed or altered from any distribution 00024 of the source. 00025 00026 4. Derivative works are permitted, but they must carry this notice 00027 in full and credit the original source. 00028 00029 00030 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 00031 00032 00033 @version Initial version, October 2004 00034 @author Kris 00035 00036 Note that this package and documentation is built around the ICU 00037 project (http://oss.software.ibm.com/icu/). Below is the license 00038 statement as specified by that software: 00039 00040 00041 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 00042 00043 00044 ICU License - ICU 1.8.1 and later 00045 00046 COPYRIGHT AND PERMISSION NOTICE 00047 00048 Copyright (c) 1995-2003 International Business Machines Corporation and 00049 others. 00050 00051 All rights reserved. 00052 00053 Permission is hereby granted, free of charge, to any person obtaining a 00054 copy of this software and associated documentation files (the 00055 "Software"), to deal in the Software without restriction, including 00056 without limitation the rights to use, copy, modify, merge, publish, 00057 distribute, and/or sell copies of the Software, and to permit persons 00058 to whom the Software is furnished to do so, provided that the above 00059 copyright notice(s) and this permission notice appear in all copies of 00060 the Software and that both the above copyright notice(s) and this 00061 permission notice appear in supporting documentation. 00062 00063 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 00064 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 00065 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT 00066 OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 00067 HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL 00068 INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING 00069 FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 00070 NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION 00071 WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 00072 00073 Except as contained in this notice, the name of a copyright holder 00074 shall not be used in advertising or otherwise to promote the sale, use 00075 or other dealings in this Software without prior written authorization 00076 of the copyright holder. 00077 00078 ---------------------------------------------------------------------- 00079 00080 All trademarks and registered trademarks mentioned herein are the 00081 property of their respective owners. 00082 00083 *******************************************************************************/ 00084 00085 module mango.icu.UConverter; 00086 00087 private import mango.icu.ICU; 00088 00089 /******************************************************************************* 00090 00091 *******************************************************************************/ 00092 00093 struct UAdjust // used with encode() & decode() methods 00094 { 00095 uint input, // how much was read from the input 00096 output; // how much was written to the output 00097 } 00098 00099 /******************************************************************************* 00100 00101 *******************************************************************************/ 00102 00103 interface ITranscoder 00104 { 00105 void reset (); 00106 00107 bool convert (void[] input, void[] output, inout UAdjust x, bool flush); 00108 } 00109 00110 /******************************************************************************* 00111 00112 This API is used to convert codepage or character encoded data to 00113 and from UTF-16. You can open a converter with ucnv_open(). With 00114 that converter, you can get its properties, set options, convert 00115 your data and close the converter. 00116 00117 Since many software programs recogize different converter names 00118 for different types of converters, there are other functions in 00119 this API to iterate over the converter aliases. 00120 00121 See <A HREF="http://oss.software.ibm.com/icu/apiref/ucnv_8h.html"> 00122 this page</A> for full details. 00123 00124 *******************************************************************************/ 00125 00126 class UConverter : ICU 00127 { 00128 private Handle handle; 00129 00130 00131 00132 /*********************************************************************** 00133 00134 Creates a UConverter object with the names specified as a 00135 string. 00136 00137 The actual name will be resolved with the alias file using 00138 a case-insensitive string comparison that ignores delimiters 00139 '-', '_', and ' ' (dash, underscore, and space). E.g., the 00140 names "UTF8", "utf-8", and "Utf 8" are all equivalent. If null 00141 is passed for the converter name, it will create one with the 00142 getDefaultName() return value. 00143 00144 A converter name may contain options like a locale specification 00145 to control the specific behavior of the converter instantiated. 00146 The meaning of the options depends on the particular converter: 00147 if an option is not defined for or recognized, it is ignored. 00148 00149 Options are appended to the converter name string, with an 00150 OptionSepChar between the name and the first option and also 00151 between adjacent options. 00152 00153 The conversion behavior and names can vary between platforms, 00154 and ICU may convert some characters differently from other 00155 platforms. Details on this topic are in the User's Guide. 00156 00157 ***********************************************************************/ 00158 00159 this (char[] name) 00160 { 00161 Error e; 00162 00163 handle = ucnv_open (toString (name), e); 00164 if (isError (e)) 00165 exception ("failed to create converter for '"~name~"'"); 00166 } 00167 00168 /*********************************************************************** 00169 00170 Deletes the unicode converter and releases resources 00171 associated with just this instance. Does not free up 00172 shared converter tables. 00173 00174 ***********************************************************************/ 00175 00176 ~this () 00177 { 00178 ucnv_close (handle); 00179 } 00180 00181 /*********************************************************************** 00182 00183 Do a fuzzy compare of two converter/alias names. The 00184 comparison is case-insensitive. It also ignores the 00185 characters '-', '_', and ' ' (dash, underscore, and space). 00186 Thus the strings "UTF-8", "utf_8", and "Utf 8" are exactly 00187 equivalent 00188 00189 ***********************************************************************/ 00190 00191 static final int compareNames (char[] a, char[] b) 00192 { 00193 return ucnv_compareNames (toString(a), toString(b)); 00194 } 00195 00196 /*********************************************************************** 00197 00198 Resets the state of this converter to the default state. 00199 00200 This is used in the case of an error, to restart a 00201 conversion from a known default state. It will also 00202 empty the internal output buffers. 00203 00204 ***********************************************************************/ 00205 00206 void reset () 00207 { 00208 ucnv_reset (handle); 00209 } 00210 00211 /*********************************************************************** 00212 00213 Resets the from-Unicode part of this converter state to the 00214 default state. 00215 00216 This is used in the case of an error to restart a conversion 00217 from Unicode to a known default state. It will also empty the 00218 internal output buffers used for the conversion from Unicode 00219 codepoints. 00220 00221 ***********************************************************************/ 00222 00223 void resetDecoder () 00224 { 00225 ucnv_resetToUnicode (handle); 00226 } 00227 00228 /*********************************************************************** 00229 00230 Resets the from-Unicode part of this converter state to the 00231 default state. 00232 00233 This is used in the case of an error to restart a conversion 00234 from Unicode to a known default state. It will also empty the 00235 internal output buffers used for the conversion from Unicode 00236 codepoints. 00237 00238 ***********************************************************************/ 00239 00240 void resetEncoder () 00241 { 00242 ucnv_resetFromUnicode (handle); 00243 } 00244 00245 /*********************************************************************** 00246 00247 Returns the maximum number of bytes that are output per 00248 UChar in conversion from Unicode using this converter. 00249 00250 The returned number can be used to calculate the size of 00251 a target buffer for conversion from Unicode. 00252 00253 This number may not be the same as the maximum number of 00254 bytes per "conversion unit". In other words, it may not 00255 be the intuitively expected number of bytes per character 00256 that would be published for a charset, and may not fulfill 00257 any other purpose than the allocation of an output buffer 00258 of guaranteed sufficient size for a given input length and 00259 converter. 00260 00261 Examples for special cases that are taken into account: 00262 00263 * Supplementary code points may convert to more bytes than 00264 BMP code points. This function returns bytes per UChar 00265 (UTF-16 code unit), not per Unicode code point, for efficient 00266 buffer allocation. 00267 * State-shifting output (SI/SO, escapes, etc.) from stateful 00268 converters. 00269 * When m input UChars are converted to n output bytes, then 00270 the maximum m/n is taken into account. 00271 00272 The number returned here does not take into account: 00273 00274 * callbacks which output more than one charset character 00275 sequence per call, like escape callbacks 00276 * initial and final non-character bytes that are output by 00277 some converters (automatic BOMs, initial escape sequence, 00278 final SI, etc.) 00279 00280 Examples for returned values: 00281 00282 * SBCS charsets: 1 00283 * Shift-JIS: 2 00284 * UTF-16: 2 (2 per BMP, 4 per surrogate _pair_, BOM not counted) 00285 * UTF-8: 3 (3 per BMP, 4 per surrogate _pair_) 00286 * EBCDIC_STATEFUL (EBCDIC mixed SBCS/DBCS): 3 (SO + DBCS) 00287 * ISO-2022: 3 (always outputs UTF-8) 00288 * ISO-2022-JP: 6 (4-byte escape sequences + DBCS) 00289 * ISO-2022-CN: 8 (4-byte designator sequences + 2-byte SS2/SS3 00290 + DBCS) 00291 00292 ***********************************************************************/ 00293 00294 ubyte getMaxCharSize () 00295 { 00296 return ucnv_getMaxCharSize (handle); 00297 } 00298 00299 /*********************************************************************** 00300 00301 Returns the minimum byte length for characters in this 00302 codepage. This is usually either 1 or 2. 00303 00304 ***********************************************************************/ 00305 00306 ubyte getMinCharSize () 00307 { 00308 return ucnv_getMinCharSize (handle); 00309 } 00310 00311 /*********************************************************************** 00312 00313 Gets the internal, canonical name of the converter (zero- 00314 terminated). 00315 00316 ***********************************************************************/ 00317 00318 char[] getName () 00319 { 00320 Error e; 00321 00322 char[] name = toArray (ucnv_getName (handle, e)); 00323 testError (e, "failed to get converter name"); 00324 return name; 00325 } 00326 00327 /*********************************************************************** 00328 00329 Determines if the converter contains ambiguous mappings of 00330 the same character or not 00331 00332 ***********************************************************************/ 00333 00334 bool isAmbiguous () 00335 { 00336 return cast(bool) ucnv_isAmbiguous (handle); 00337 } 00338 00339 /*********************************************************************** 00340 00341 Detects Unicode signature byte sequences at the start 00342 of the byte stream and returns the charset name of the 00343 indicated Unicode charset. A null is returned where no 00344 Unicode signature is recognized. 00345 00346 A caller can create a UConverter using the charset name. 00347 The first code unit (wchar) from the start of the stream 00348 will be U+FEFF (the Unicode BOM/signature character) and 00349 can usually be ignored. 00350 00351 ***********************************************************************/ 00352 00353 static final char[] detectSignature (void[] input) 00354 { 00355 Error e; 00356 uint len; 00357 char* name; 00358 00359 name = ucnv_detectUnicodeSignature (input, input.length, len, e); 00360 if (name == null || isError (e)) 00361 return null; 00362 return toArray (name); 00363 } 00364 00365 /*********************************************************************** 00366 00367 Converts an array of unicode characters to an array of 00368 codepage characters. 00369 00370 This function is optimized for converting a continuous 00371 stream of data in buffer-sized chunks, where the entire 00372 source and target does not fit in available buffers. 00373 00374 The source pointer is an in/out parameter. It starts out 00375 pointing where the conversion is to begin, and ends up 00376 pointing after the last UChar consumed. 00377 00378 Target similarly starts out pointer at the first available 00379 byte in the output buffer, and ends up pointing after the 00380 last byte written to the output. 00381 00382 The converter always attempts to consume the entire source 00383 buffer, unless (1.) the target buffer is full, or (2.) a 00384 failing error is returned from the current callback function. 00385 When a successful error status has been returned, it means 00386 that all of the source buffer has been consumed. At that 00387 point, the caller should reset the source and sourceLimit 00388 pointers to point to the next chunk. 00389 00390 At the end of the stream (flush==true), the input is completely 00391 consumed when *source==sourceLimit and no error code is set. 00392 The converter object is then automatically reset by this 00393 function. (This means that a converter need not be reset 00394 explicitly between data streams if it finishes the previous 00395 stream without errors.) 00396 00397 This is a stateful conversion. Additionally, even when all 00398 source data has been consumed, some data may be in the 00399 converters' internal state. Call this function repeatedly, 00400 updating the target pointers with the next empty chunk of 00401 target in case of a U_BUFFER_OVERFLOW_ERROR, and updating 00402 the source pointers with the next chunk of source when a 00403 successful error status is returned, until there are no more 00404 chunks of source data. 00405 00406 Parameters: 00407 00408 converter the Unicode converter 00409 target I/O parameter. Input : Points to the 00410 beginning of the buffer to copy codepage 00411 characters to. Output : points to after 00412 the last codepage character copied to 00413 target. 00414 targetLimit the pointer just after last of the 00415 target buffer 00416 source I/O parameter, pointer to pointer to 00417 the source Unicode character buffer. 00418 sourceLimit the pointer just after the last of 00419 the source buffer 00420 offsets if NULL is passed, nothing will happen 00421 to it, otherwise it needs to have the 00422 same number of allocated cells as target. 00423 Will fill in offsets from target to source 00424 pointer e.g: offsets[3] is equal to 6, it 00425 means that the target[3] was a result of 00426 transcoding source[6] For output data 00427 carried across calls, and other data 00428 without a specific source character 00429 (such as from escape sequences or 00430 callbacks) -1 will be placed for offsets. 00431 flush set to TRUE if the current source buffer 00432 is the last available chunk of the source, 00433 FALSE otherwise. Note that if a failing 00434 status is returned, this function may 00435 have to be called multiple times with 00436 flush set to TRUE until the source buffer 00437 is consumed. 00438 00439 ***********************************************************************/ 00440 00441 bool encode (wchar[] input, void[] output, inout UAdjust x, bool flush) 00442 { 00443 Error e; 00444 wchar* src = input; 00445 void* dst = output; 00446 wchar* srcLimit = src + input.length; 00447 void* dstLimit = dst + output.length; 00448 00449 ucnv_fromUnicode (handle, &dst, dstLimit, &src, srcLimit, null, flush, e); 00450 x.input = src - cast(wchar*) input; 00451 x.output = dst - cast(void*) output; 00452 00453 if (e == e.BufferOverflow) 00454 return true; 00455 00456 testError (e, "failed to encode"); 00457 return false; 00458 } 00459 00460 /*********************************************************************** 00461 00462 Encode the Unicode string into a codepage string. 00463 00464 This function is a more convenient but less powerful version 00465 of encode(). It is only useful for whole strings, not 00466 for streaming conversion. The maximum output buffer capacity 00467 required (barring output from callbacks) should be calculated 00468 using getMaxCharSize(). 00469 00470 ***********************************************************************/ 00471 00472 uint encode (wchar[] input, void[] output) 00473 { 00474 Error e; 00475 uint len; 00476 00477 len = ucnv_fromUChars (handle, output, output.length, input, input.length, e); 00478 testError (e, "failed to encode"); 00479 return len; 00480 } 00481 00482 /*********************************************************************** 00483 00484 Converts a buffer of codepage bytes into an array of unicode 00485 UChars characters. 00486 00487 This function is optimized for converting a continuous stream 00488 of data in buffer-sized chunks, where the entire source and 00489 target does not fit in available buffers. 00490 00491 The source pointer is an in/out parameter. It starts out pointing 00492 where the conversion is to begin, and ends up pointing after the 00493 last byte of source consumed. 00494 00495 Target similarly starts out pointer at the first available UChar 00496 in the output buffer, and ends up pointing after the last UChar 00497 written to the output. It does NOT necessarily keep UChar sequences 00498 together. 00499 00500 The converter always attempts to consume the entire source buffer, 00501 unless (1.) the target buffer is full, or (2.) a failing error is 00502 returned from the current callback function. When a successful 00503 error status has been returned, it means that all of the source 00504 buffer has been consumed. At that point, the caller should reset 00505 the source and sourceLimit pointers to point to the next chunk. 00506 00507 At the end of the stream (flush==true), the input is completely 00508 consumed when *source==sourceLimit and no error code is set The 00509 converter object is then automatically reset by this function. 00510 (This means that a converter need not be reset explicitly between 00511 data streams if it finishes the previous stream without errors.) 00512 00513 This is a stateful conversion. Additionally, even when all source 00514 data has been consumed, some data may be in the converters' internal 00515 state. Call this function repeatedly, updating the target pointers 00516 with the next empty chunk of target in case of a BufferOverflow, and 00517 updating the source pointers with the next chunk of source when a 00518 successful error status is returned, until there are no more chunks 00519 of source data. 00520 00521 Parameters: 00522 converter the Unicode converter 00523 target I/O parameter. Input : Points to the beginning 00524 of the buffer to copy UChars into. Output : 00525 points to after the last UChar copied. 00526 targetLimit the pointer just after the end of the target 00527 buffer 00528 source I/O parameter, pointer to pointer to the source 00529 codepage buffer. 00530 sourceLimit the pointer to the byte after the end of the 00531 source buffer 00532 offsets if NULL is passed, nothing will happen to 00533 it, otherwise it needs to have the same 00534 number of allocated cells as target. Will 00535 fill in offsets from target to source pointer 00536 e.g: offsets[3] is equal to 6, it means that 00537 the target[3] was a result of transcoding 00538 source[6] For output data carried across 00539 calls, and other data without a specific 00540 source character (such as from escape 00541 sequences or callbacks) -1 will be placed 00542 for offsets. 00543 flush set to true if the current source buffer 00544 is the last available chunk of the source, 00545 false otherwise. Note that if a failing 00546 status is returned, this function may have 00547 to be called multiple times with flush set 00548 to true until the source buffer is consumed. 00549 00550 ***********************************************************************/ 00551 00552 bool decode (void[] input, wchar[] output, inout UAdjust x, bool flush) 00553 { 00554 Error e; 00555 void* src = input; 00556 wchar* dst = output; 00557 void* srcLimit = src + input.length; 00558 wchar* dstLimit = dst + output.length; 00559 00560 ucnv_toUnicode (handle, &dst, dstLimit, &src, srcLimit, null, flush, e); 00561 x.input = src - cast(void*) input; 00562 x.output = dst - cast(wchar*) output; 00563 00564 if (e == e.BufferOverflow) 00565 return true; 00566 00567 testError (e, "failed to decode"); 00568 return false; 00569 } 00570 00571 /*********************************************************************** 00572 00573 Decode the codepage string into a Unicode string. 00574 00575 This function is a more convenient but less powerful version 00576 of decode(). It is only useful for whole strings, not for 00577 streaming conversion. The maximum output buffer capacity 00578 required (barring output from callbacks) will be 2*src.length 00579 (each char may be converted into a surrogate pair) 00580 00581 ***********************************************************************/ 00582 00583 uint decode (void[] input, wchar[] output) 00584 { 00585 Error e; 00586 uint len; 00587 00588 len = ucnv_toUChars (handle, output, output.length, input, input.length, e); 00589 testError (e, "failed to decode"); 00590 return len; 00591 } 00592 00593 /********************************************************************** 00594 00595 Iterate over the available converter names 00596 00597 **********************************************************************/ 00598 00599 static int opApply (int delegate(inout char[] element) dg) 00600 { 00601 char[] name; 00602 int result; 00603 uint count = ucnv_countAvailable (); 00604 00605 for (uint i=0; i < count; ++i) 00606 { 00607 name = toArray (ucnv_getAvailableName (i)); 00608 result = dg (name); 00609 if (result) 00610 break; 00611 } 00612 return result; 00613 } 00614 00615 /*********************************************************************** 00616 00617 ***********************************************************************/ 00618 00619 ITranscoder createTranscoder (UConverter dst) 00620 { 00621 return new UTranscoder (this, dst); 00622 } 00623 00624 /********************************************************************** 00625 00626 **********************************************************************/ 00627 00628 private class UTranscoder : ITranscoder 00629 { 00630 private UConverter cSrc, 00631 cDst; 00632 private bool clear = true; 00633 00634 /************************************************************** 00635 00636 **************************************************************/ 00637 00638 this (UConverter src, UConverter dst) 00639 { 00640 cSrc = src; 00641 cDst = dst; 00642 } 00643 00644 /************************************************************** 00645 00646 **************************************************************/ 00647 00648 void reset () 00649 { 00650 clear = true; 00651 } 00652 00653 /************************************************************** 00654 00655 **************************************************************/ 00656 00657 bool convert (void[] input, void[] output, inout UAdjust x, bool flush) 00658 { 00659 Error e; 00660 void* src = input; 00661 void* dst = output; 00662 void* srcLimit = src + input.length; 00663 void* dstLimit = dst + output.length; 00664 00665 ucnv_convertEx (cDst.handle, cSrc.handle, &dst, dstLimit, 00666 &src, srcLimit, null, null, null, null, 00667 clear, flush, e); 00668 clear = false; 00669 x.input = src - cast(void*) input; 00670 x.output = dst - cast(void*) output; 00671 00672 if (e == e.BufferOverflow) 00673 return true; 00674 00675 testError (e, "failed to decode"); 00676 return false; 00677 } 00678 } 00679 00680 00681 /*********************************************************************** 00682 00683 Bind the ICU functions from a shared library. This is 00684 complicated by the issues regarding D and DLLs on the 00685 Windows platform 00686 00687 ***********************************************************************/ 00688 00689 private static void* library; 00690 00691 /*********************************************************************** 00692 00693 ***********************************************************************/ 00694 00695 private static extern (C) 00696 { 00697 int function (char*, char*) ucnv_compareNames; 00698 Handle function (char*, inout Error) ucnv_open; 00699 char* function (void*, uint, inout uint, inout Error) ucnv_detectUnicodeSignature; 00700 void function (Handle) ucnv_close; 00701 void function (Handle) ucnv_reset; 00702 int function (Handle) ucnv_resetToUnicode; 00703 int function (Handle) ucnv_resetFromUnicode; 00704 ubyte function (Handle) ucnv_getMaxCharSize; 00705 ubyte function (Handle) ucnv_getMinCharSize; 00706 char* function (Handle, inout Error) ucnv_getName; 00707 uint function (Handle, wchar*, uint, void*, uint, inout Error) ucnv_toUChars; 00708 uint function (Handle, void*, uint, wchar*, uint, inout Error) ucnv_fromUChars; 00709 void function (Handle, void**, void*, wchar**, wchar*, int*, ubyte, inout Error) ucnv_fromUnicode; 00710 void function (Handle, wchar**, wchar*, void**, void*, int*, ubyte, inout Error) ucnv_toUnicode; 00711 void function (Handle, Handle, void**, void*, void**, void*, wchar*, wchar*, wchar*, wchar*, ubyte, ubyte, inout Error) ucnv_convertEx; 00712 ubyte function (Handle) ucnv_isAmbiguous; 00713 char* function (uint) ucnv_getAvailableName; 00714 uint function () ucnv_countAvailable; 00715 } 00716 00717 /*********************************************************************** 00718 00719 ***********************************************************************/ 00720 00721 static FunctionLoader.Bind[] targets = 00722 [ 00723 {cast(void**) &ucnv_open, "ucnv_open"}, 00724 {cast(void**) &ucnv_close, "ucnv_close"}, 00725 {cast(void**) &ucnv_reset, "ucnv_reset"}, 00726 {cast(void**) &ucnv_resetToUnicode, "ucnv_resetToUnicode"}, 00727 {cast(void**) &ucnv_resetFromUnicode, "ucnv_resetFromUnicode"}, 00728 {cast(void**) &ucnv_compareNames, "ucnv_compareNames"}, 00729 {cast(void**) &ucnv_getMaxCharSize, "ucnv_getMaxCharSize"}, 00730 {cast(void**) &ucnv_getMinCharSize, "ucnv_getMinCharSize"}, 00731 {cast(void**) &ucnv_getName, "ucnv_getName"}, 00732 {cast(void**) &ucnv_detectUnicodeSignature, "ucnv_detectUnicodeSignature"}, 00733 {cast(void**) &ucnv_toUChars, "ucnv_toUChars"}, 00734 {cast(void**) &ucnv_fromUChars, "ucnv_fromUChars"}, 00735 {cast(void**) &ucnv_toUnicode, "ucnv_toUnicode"}, 00736 {cast(void**) &ucnv_fromUnicode, "ucnv_fromUnicode"}, 00737 {cast(void**) &ucnv_convertEx, "ucnv_convertEx"}, 00738 {cast(void**) &ucnv_isAmbiguous, "ucnv_isAmbiguous"}, 00739 {cast(void**) &ucnv_countAvailable, "ucnv_countAvailable"}, 00740 {cast(void**) &ucnv_getAvailableName, "ucnv_getAvailableName"}, 00741 ]; 00742 00743 /*********************************************************************** 00744 00745 ***********************************************************************/ 00746 00747 static this () 00748 { 00749 library = FunctionLoader.bind (icuuc, targets); 00750 /+ 00751 foreach (char[] name; UConverter) 00752 printf ("%.*s\n", name); 00753 +/ 00754 } 00755 00756 /*********************************************************************** 00757 00758 ***********************************************************************/ 00759 00760 static ~this () 00761 { 00762 FunctionLoader.unbind (library); 00763 } 00764 }