Mercurial > projects > dwt-addons
comparison dwtx/dwtxhelper/mangoicu/UConverter.d @ 91:11e8159caf7a
make the mango icu fork work.
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Mon, 07 Jul 2008 15:53:07 +0200 |
parents | 040da1cb0d76 |
children |
comparison
equal
deleted
inserted
replaced
90:7ffeace6c47f | 91:11e8159caf7a |
---|---|
80 All trademarks and registered trademarks mentioned herein are the | 80 All trademarks and registered trademarks mentioned herein are the |
81 property of their respective owners. | 81 property of their respective owners. |
82 | 82 |
83 *******************************************************************************/ | 83 *******************************************************************************/ |
84 | 84 |
85 module dwtx.dwthelper.mangoicu.UConverter; | 85 module dwtx.dwtxhelper.mangoicu.UConverter; |
86 | 86 |
87 private import dwtx.dwthelper.mangoicu.ICU; | 87 private import dwtx.dwtxhelper.mangoicu.ICU; |
88 | 88 |
89 /******************************************************************************* | 89 /******************************************************************************* |
90 | 90 |
91 *******************************************************************************/ | 91 *******************************************************************************/ |
92 | 92 |
156 | 156 |
157 ***********************************************************************/ | 157 ***********************************************************************/ |
158 | 158 |
159 this (char[] name) | 159 this (char[] name) |
160 { | 160 { |
161 Error e; | 161 UErrorCode e; |
162 | 162 |
163 handle = ucnv_open (toString (name), e); | 163 handle = ucnv_open (toString (name), e); |
164 if (isError (e)) | 164 if (isError (e)) |
165 exception ("failed to create converter for '"~name~"'"); | 165 exception ("failed to create converter for '"~name~"'"); |
166 } | 166 } |
315 | 315 |
316 ***********************************************************************/ | 316 ***********************************************************************/ |
317 | 317 |
318 char[] getName () | 318 char[] getName () |
319 { | 319 { |
320 Error e; | 320 UErrorCode e; |
321 | 321 |
322 char[] name = toArray (ucnv_getName (handle, e)); | 322 char[] name = toArray (ucnv_getName (handle, e)); |
323 testError (e, "failed to get converter name"); | 323 testError (e, "failed to get converter name"); |
324 return name; | 324 return name; |
325 } | 325 } |
350 | 350 |
351 ***********************************************************************/ | 351 ***********************************************************************/ |
352 | 352 |
353 static final char[] detectSignature (void[] input) | 353 static final char[] detectSignature (void[] input) |
354 { | 354 { |
355 Error e; | 355 UErrorCode e; |
356 uint len; | 356 uint len; |
357 char* name; | 357 char* name; |
358 | 358 |
359 name = ucnv_detectUnicodeSignature (input.ptr, input.length, len, e); | 359 name = ucnv_detectUnicodeSignature (input.ptr, input.length, len, e); |
360 if (name == null || isError (e)) | 360 if (name == null || isError (e)) |
438 | 438 |
439 ***********************************************************************/ | 439 ***********************************************************************/ |
440 | 440 |
441 bool encode (wchar[] input, void[] output, inout UAdjust x, bool flush) | 441 bool encode (wchar[] input, void[] output, inout UAdjust x, bool flush) |
442 { | 442 { |
443 Error e; | 443 UErrorCode e; |
444 wchar* src = input.ptr; | 444 wchar* src = input.ptr; |
445 void* dst = output.ptr; | 445 void* dst = output.ptr; |
446 wchar* srcLimit = src + input.length; | 446 wchar* srcLimit = src + input.length; |
447 void* dstLimit = dst + output.length; | 447 void* dstLimit = dst + output.length; |
448 | 448 |
469 | 469 |
470 ***********************************************************************/ | 470 ***********************************************************************/ |
471 | 471 |
472 uint encode (wchar[] input, void[] output) | 472 uint encode (wchar[] input, void[] output) |
473 { | 473 { |
474 Error e; | 474 UErrorCode e; |
475 uint len; | 475 uint len; |
476 | 476 |
477 len = ucnv_fromUChars (handle, output.ptr, output.length, input.ptr, input.length, e); | 477 len = ucnv_fromUChars (handle, output.ptr, output.length, input.ptr, input.length, e); |
478 testError (e, "failed to encode"); | 478 testError (e, "failed to encode"); |
479 return len; | 479 return len; |
549 | 549 |
550 ***********************************************************************/ | 550 ***********************************************************************/ |
551 | 551 |
552 bool decode (void[] input, wchar[] output, inout UAdjust x, bool flush) | 552 bool decode (void[] input, wchar[] output, inout UAdjust x, bool flush) |
553 { | 553 { |
554 Error e; | 554 UErrorCode e; |
555 void* src = input.ptr; | 555 void* src = input.ptr; |
556 wchar* dst = output.ptr; | 556 wchar* dst = output.ptr; |
557 void* srcLimit = src + input.length; | 557 void* srcLimit = src + input.length; |
558 wchar* dstLimit = dst + output.length; | 558 wchar* dstLimit = dst + output.length; |
559 | 559 |
580 | 580 |
581 ***********************************************************************/ | 581 ***********************************************************************/ |
582 | 582 |
583 uint decode (void[] input, wchar[] output) | 583 uint decode (void[] input, wchar[] output) |
584 { | 584 { |
585 Error e; | 585 UErrorCode e; |
586 uint len; | 586 uint len; |
587 | 587 |
588 len = ucnv_toUChars (handle, output.ptr, output.length, input.ptr, input.length, e); | 588 len = ucnv_toUChars (handle, output.ptr, output.length, input.ptr, input.length, e); |
589 testError (e, "failed to decode"); | 589 testError (e, "failed to decode"); |
590 return len; | 590 return len; |
654 | 654 |
655 **************************************************************/ | 655 **************************************************************/ |
656 | 656 |
657 bool convert (void[] input, void[] output, inout UAdjust x, bool flush) | 657 bool convert (void[] input, void[] output, inout UAdjust x, bool flush) |
658 { | 658 { |
659 Error e; | 659 UErrorCode e; |
660 void* src = input.ptr; | 660 void* src = input.ptr; |
661 void* dst = output.ptr; | 661 void* dst = output.ptr; |
662 void* srcLimit = src + input.length; | 662 void* srcLimit = src + input.length; |
663 void* dstLimit = dst + output.length; | 663 void* dstLimit = dst + output.length; |
664 | 664 |
693 ***********************************************************************/ | 693 ***********************************************************************/ |
694 | 694 |
695 private static extern (C) | 695 private static extern (C) |
696 { | 696 { |
697 int function (char*, char*) ucnv_compareNames; | 697 int function (char*, char*) ucnv_compareNames; |
698 Handle function (char*, inout Error) ucnv_open; | 698 Handle function (char*, inout UErrorCode) ucnv_open; |
699 char* function (void*, uint, inout uint, inout Error) ucnv_detectUnicodeSignature; | 699 char* function (void*, uint, inout uint, inout UErrorCode) ucnv_detectUnicodeSignature; |
700 void function (Handle) ucnv_close; | 700 void function (Handle) ucnv_close; |
701 void function (Handle) ucnv_reset; | 701 void function (Handle) ucnv_reset; |
702 int function (Handle) ucnv_resetToUnicode; | 702 int function (Handle) ucnv_resetToUnicode; |
703 int function (Handle) ucnv_resetFromUnicode; | 703 int function (Handle) ucnv_resetFromUnicode; |
704 ubyte function (Handle) ucnv_getMaxCharSize; | 704 ubyte function (Handle) ucnv_getMaxCharSize; |
705 ubyte function (Handle) ucnv_getMinCharSize; | 705 ubyte function (Handle) ucnv_getMinCharSize; |
706 char* function (Handle, inout Error) ucnv_getName; | 706 char* function (Handle, inout UErrorCode) ucnv_getName; |
707 uint function (Handle, wchar*, uint, void*, uint, inout Error) ucnv_toUChars; | 707 uint function (Handle, wchar*, uint, void*, uint, inout UErrorCode) ucnv_toUChars; |
708 uint function (Handle, void*, uint, wchar*, uint, inout Error) ucnv_fromUChars; | 708 uint function (Handle, void*, uint, wchar*, uint, inout UErrorCode) ucnv_fromUChars; |
709 void function (Handle, void**, void*, wchar**, wchar*, int*, ubyte, inout Error) ucnv_fromUnicode; | 709 void function (Handle, void**, void*, wchar**, wchar*, int*, ubyte, inout UErrorCode) ucnv_fromUnicode; |
710 void function (Handle, wchar**, wchar*, void**, void*, int*, ubyte, inout Error) ucnv_toUnicode; | 710 void function (Handle, wchar**, wchar*, void**, void*, int*, ubyte, inout UErrorCode) ucnv_toUnicode; |
711 void function (Handle, Handle, void**, void*, void**, void*, wchar*, wchar*, wchar*, wchar*, ubyte, ubyte, inout Error) ucnv_convertEx; | 711 void function (Handle, Handle, void**, void*, void**, void*, wchar*, wchar*, wchar*, wchar*, ubyte, ubyte, inout UErrorCode) ucnv_convertEx; |
712 ubyte function (Handle) ucnv_isAmbiguous; | 712 ubyte function (Handle) ucnv_isAmbiguous; |
713 char* function (uint) ucnv_getAvailableName; | 713 char* function (uint) ucnv_getAvailableName; |
714 uint function () ucnv_countAvailable; | 714 uint function () ucnv_countAvailable; |
715 } | 715 } |
716 | 716 |