00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
#ifndef VTK_STRING_CONVERTER_H_
00069
# define VTK_STRING_CONVERTER_H_
00070
# include "vtkExtensionsCommonConfigure.h"
00071
# include "vtkExtensionsTypes.h"
00072
# include "vtkExtensionsExceptions.h"
00073
00074
VTK_EXTENSIONS_NAMESPACE_BEGIN
00075
00142 class VTK_EXTENSIONS_COMMON_EXPORT vtkStringConverter
00143 {
00144
public:
00147 static const vtkUCS4ChType UNI_REPLACEMENT_CHAR;
00148 static const vtkUCS4ChType UNI_MAX_BMP;
00149 static const vtkUCS4ChType UNI_MAX_UTF16;
00150 static const vtkUCS4ChType UNI_MAX_UTF32;
00200 static const vtkUCS2ChType UNI_SIGNATURE_UCS2[2];
00201 static const vtkUCS4ChType UNI_SIGNATURE_UCS4[2];
00202 static const vtkUTF8ChType UNI_SIGNATURE_UTF8[4];
00203 static const vtkUTF16ChType UNI_SIGNATURE_UTF16[2];
00208 static const vtkUCS4ChType ISO8859_REPLACEMENT_CHAR;
00209 static const vtkUCS4ChType ISO8859_MAX_CHAR;
00212 enum ConversionResult
00213 {
00214 eConversionOK = 0,
00215 eSourceExhausted,
00216 eTargetExhausted,
00217 eSourceIllegal,
00218 eSourceCorrupt,
00219 eInvalidEncoding
00220 };
00221
00222 enum ConversionFlags
00223 {
00224 eStrictConversion = 0,
00225 eLenientConversion
00226 };
00227
00228 enum EncodingEnum
00229 {
00230 eUnknownEncoding = 0,
00231 eIso8859_1 = 1,
00232 eIso8859_2 = 2,
00233 eIso8859_3 = 3,
00234 eIso8859_4 = 4,
00235 eIso8859_5 = 5,
00236 eIso8859_6 = 6,
00237 eIso8859_7 = 7,
00238 eIso8859_8 = 8,
00239 eIso8859_9 = 9,
00240 eIso8859_10 = 10,
00241 eIso8859_11 = 11,
00242 eIso8859_12 = eUnknownEncoding,
00243 eIso8859_13 = 13,
00244 eIso8859_14 = 14,
00245 eIso8859_15 = 15,
00246 eIso8859_16 = 16,
00247 eLatin1 = eIso8859_1,
00248 eLatin2 = eIso8859_2,
00249 eLatin3 = eIso8859_3,
00250 eLatin4 = eIso8859_4,
00251 eCyrillic = eIso8859_5,
00252 eArabic = eIso8859_6,
00253 eGreek = eIso8859_7,
00254 eHebrew = eIso8859_8,
00255 eLatin5 = eIso8859_9,
00256 eLatin6 = eIso8859_10,
00257 eThai = eIso8859_11,
00258 eLatin7 = eIso8859_13,
00259 eLatin8 = eIso8859_14,
00260 eLatin9 = eIso8859_15,
00261 eLatin10 = eIso8859_16,
00262 eUCS4,
00263 eUCS2,
00264 eUTF8,
00265 eUTF16,
00266 eUTF32
00267 };
00268
00272
static int SizeofUTF8 (
const vtkUTF16ChType* aSrc,
00273
const vtkUTF16ChType* aEnd,
00274 ConversionFlags = eStrictConversion)
00275
THROW_SPEC();
00276
00280
static int SizeofUTF8 (
const vtkUTF32ChType* aSrc,
00281
const vtkUTF32ChType* aEnd,
00282 ConversionFlags = eStrictConversion)
00283
THROW_SPEC();
00284
00288
static int SizeofUTF8 (
const char* aSrc,
00289
const char* aEnd,
00290 ConversionFlags = eStrictConversion)
00291
THROW_SPEC();
00292
00293
static int SizeofUTF8fromUCS4 (
const vtkUCS4ChType* aSrc,
00294
const vtkUCS4ChType* aEnd,
00295 ConversionFlags aFlags)
00296
THROW_SPEC();
00297
00301
static int SizeofUTF16 (
const vtkUTF32ChType* aSrc,
00302
const vtkUTF32ChType* aEnd,
00303 ConversionFlags = eStrictConversion)
00304
THROW_SPEC();
00305
00309
static int SizeofUTF16 (
const vtkUTF8ChType* aSrc,
00310
const vtkUTF8ChType* aEnd,
00311 ConversionFlags = eStrictConversion)
00312
THROW_SPEC();
00313
00317
static int SizeofUTF16 (
const char* aSrc,
00318
const char* aEnd,
00319 ConversionFlags = eStrictConversion)
00320
THROW_SPEC();
00321
00325
static int SizeofUTF32 (
const vtkUTF16ChType* aSrc,
00326
const vtkUTF16ChType* aEnd,
00327 ConversionFlags = eStrictConversion)
00328
THROW_SPEC();
00329
00333
static int SizeofUTF32 (
const vtkUTF8ChType* aSrc,
00334
const vtkUTF8ChType* aEnd,
00335 ConversionFlags = eStrictConversion)
00336
THROW_SPEC();
00337
00338
static int SizeofUCS4 (
const vtkUTF8ChType* aSrc,
00339
const vtkUTF8ChType* aEnd,
00340 ConversionFlags = eStrictConversion)
00341
THROW_SPEC();
00342
00343
static int SizeofUCS4 (
const char* aSrc,
00344
const char* aEnd,
00345 EncodingEnum = eLatin1)
00346
THROW_SPEC();
00347
00351
static int SizeofLatin1 (
const vtkUTF8ChType* aSrc,
00352
const vtkUTF8ChType* aEnd,
00353 ConversionFlags = eStrictConversion)
00354
THROW_SPEC();
00355
00359
static int SizeofLatin1 (
const vtkUTF16ChType* aSrc,
00360
const vtkUTF16ChType* aEnd,
00361 ConversionFlags = eStrictConversion)
00362
THROW_SPEC();
00363
00364
00365
static int ConvertUTF8toUTF16 (
const vtkUTF8ChType** srcStart,
00366
const vtkUTF8ChType* srcEnd,
00367 vtkUTF16ChType** dstStart,
00368 vtkUTF16ChType* dstEnd,
00369 ConversionFlags = eStrictConversion)
00370
THROW_SPEC();
00371
00372
static int ConvertUTF16toUTF8 (
const vtkUTF16ChType** srcStart,
00373
const vtkUTF16ChType* srcEnd,
00374 vtkUTF8ChType** dstStart,
00375 vtkUTF8ChType* dstEnd,
00376 ConversionFlags = eStrictConversion)
00377
THROW_SPEC();
00378
00379
static int ConvertUTF8toUTF32 (
const vtkUTF8ChType** srcStart,
00380
const vtkUTF8ChType* srcEnd,
00381 vtkUTF32ChType** dstStart,
00382 vtkUTF32ChType* dstEnd,
00383 ConversionFlags = eStrictConversion)
00384
THROW_SPEC();
00385
00386
static int ConvertUTF32toUTF8 (
const vtkUTF32ChType** srcStart,
00387
const vtkUTF32ChType* srcEnd,
00388 vtkUTF8ChType** dstStart,
00389 vtkUTF8ChType* dstEnd,
00390 ConversionFlags = eStrictConversion)
00391
THROW_SPEC();
00392
00393
static int ConvertUTF16toUTF32 (
const vtkUTF16ChType** srcStart,
00394
const vtkUTF16ChType* srcEnd,
00395 vtkUTF32ChType** dstStart,
00396 vtkUTF32ChType* dstEnd,
00397 ConversionFlags = eStrictConversion)
00398
THROW_SPEC();
00399
00400
static int ConvertUTF32toUTF16 (
const vtkUTF32ChType** srcStart,
00401
const vtkUTF32ChType* srcEnd,
00402 vtkUTF16ChType** dstStart,
00403 vtkUTF16ChType* dstEnd,
00404 ConversionFlags = eStrictConversion)
00405
THROW_SPEC();
00406
00407
static int ConvertUCS4toUTF8 (
const vtkUCS4ChType** aSrcStart,
00408
const vtkUCS4ChType* aSrcEnd,
00409 vtkUTF8ChType** aDstStart,
00410 vtkUTF8ChType* aDstEnd,
00411 ConversionFlags = eStrictConversion)
00412
THROW_SPEC();
00413
00414
static int ConvertUTF8toUCS4 (
const vtkUTF8ChType** aSrcStart,
00415
const vtkUTF8ChType* aSrcEnd,
00416 vtkUCS4ChType** aDstStart,
00417 vtkUCS4ChType* aDstEnd,
00418 ConversionFlags = eStrictConversion)
00419
THROW_SPEC();
00420
00421
static int ConvertISO8859toUCS4 (
const unsigned char** aSrcStart,
00422
const unsigned char* aSrcEnd,
00423 vtkUCS4ChType** aDstStart,
00424 vtkUCS4ChType* aDstEnd,
00425 EncodingEnum = eLatin1)
00426
THROW_SPEC();
00427
00428
static bool IsLegalUTF8Sequence (
const vtkUTF8ChType* src,
00429
const vtkUTF8ChType* srcEnd)
00430
THROW_SPEC();
00431
00436
static int SizeofUTF7 (
const vtkUCS2ChType* start,
00437
const vtkUCS2ChType* end,
00438
int optional,
int verbose)
00439
THROW_SPEC();
00440
00444
static int SizeofUCS2 (
const char* start,
const char* end)
00445
THROW_SPEC();
00446
00467
static int ConvertUCS2toUTF7 (
const vtkUCS2ChType** srcStart,
00468
const vtkUCS2ChType* srcEnd,
00469
char** dstStart,
00470
char* dstEnd,
00471
int optional,
int verbose)
00472
THROW_SPEC();
00473
00474
static int ConvertUTF7toUCS2 (
const char** srcStart,
00475
const char* srcEnd,
00476 vtkUCS2ChType** dstStart,
00477 vtkUCS2ChType* dstEnd)
00478
THROW_SPEC();
00481
static int ConvertUTF8toLatin1 (
const vtkUTF8ChType** srcStart,
00482
const vtkUTF8ChType* srcEnd,
00483
char** dstStart,
00484
char* dstEnd,
00485 ConversionFlags = eStrictConversion)
00486
THROW_SPEC();
00487
00488
static int ConvertUTF16toLatin1 (
const vtkUTF16ChType** srcStart,
00489
const vtkUTF16ChType* srcEnd,
00490
char** dstStart,
00491
char* dstEnd,
00492 ConversionFlags = eStrictConversion)
00493
THROW_SPEC();
00494
00496
static int ConvertLatin1toUTF8 (
const char** srcStart,
00497
const char* srcEnd,
00498 vtkUTF8ChType** dstStart,
00499 vtkUTF8ChType* dstEnd,
00500 ConversionFlags = eStrictConversion)
00501
THROW_SPEC();
00502
00503
static int ConvertLatin1toUTF16 (
const char** srcStart,
00504
const char* srcEnd,
00505 vtkUTF16ChType** dstStart,
00506 vtkUTF16ChType* dstEnd,
00507 ConversionFlags = eStrictConversion)
00508
THROW_SPEC();
00509
00510
private:
00511 vtkStringConverter (
void);
00512 ~vtkStringConverter();
00513 vtkStringConverter (
const vtkStringConverter&);
00514
void operator= (
const vtkStringConverter&);
00515 };
00516
00517
VTK_EXTENSIONS_NAMESPACE_END
00518
00519
#endif
00520
00521
00522
00523