14 #ifndef vtkDICOMCharacterSet_h
15 #define vtkDICOMCharacterSet_h
17 #include "vtkSystemIncludes.h"
18 #include "vtkDICOMModule.h"
19 #include "vtkDICOMConfig.h"
82 ISO_2022_IR_13_87 = 35,
84 ISO_2022_IR_87_159 = 38,
85 ISO_2022_IR_13_87_159 = 39,
100 X_ISO_2022_JP_1 = 59,
101 X_ISO_2022_JP_2 = 60,
102 X_ISO_2022_JP_EXT = 61,
145 this->Key = KeyFromString(name.data(), name.length()); }
147 this->Key = KeyFromString(name, nl); }
160 GlobalDefault = cs.
GetKey(); }
162 return GlobalDefault; }
171 GlobalOverride = b; }
172 static void GlobalOverrideOn() { GlobalOverride =
true; }
173 static void GlobalOverrideOff() { GlobalOverride =
false; }
174 static bool GetGlobalOverride() {
return GlobalOverride; }
220 unsigned char GetKey()
const {
return this->Key; }
234 std::string
FromUTF8(
const char *text,
size_t l,
size_t *lp=
nullptr)
const;
235 std::string FromUTF8(
const std::string& text)
const {
236 return FromUTF8(text.data(), text.length()); }
251 std::string
ToUTF8(
const char *text,
size_t l,
size_t *lp=
nullptr)
const;
252 std::string ToUTF8(
const std::string& text)
const {
253 return ToUTF8(text.data(), text.length()); }
265 std::string ToSafeUTF8(
const std::string& text)
const {
266 return ToSafeUTF8(text.data(), text.length()); }
278 std::string CaseFoldedUTF8(
const std::string& text)
const {
279 return CaseFoldedUTF8(text.data(), text.length()); }
287 return ((this->Key & ISO_2022_MAX) == (this->Key | ISO_2022_MIN));
292 return (this->Key >= ISO_IR_100 && this->Key <= X_LATIN10);
303 return (this->Key == ISO_IR_127 ||
304 this->Key == ISO_IR_138 ||
305 this->Key == X_CP1255 ||
306 this->Key == X_CP1256); }
362 ALTERNATE_CS = 0x00FF,
363 MULTIBYTE_G0 = 0x0100,
364 MULTIBYTE_G1 = 0x0200,
365 MULTIBYTE_G2 = 0x0400,
366 MULTIBYTE_G3 = 0x0800,
367 CHARSET96_GX = 0x1000,
368 CHARSET96_G1 = 0x2000,
369 CHARSET96_G2 = 0x4000,
370 CHARSET96_G3 = 0x8000
381 size_t AnyToUTF8(
const char *t,
size_t l, std::string *s,
int m)
const;
382 size_t UTF8ToSingleByte(
const char *t,
size_t l, std::string *s,
int m)
const;
383 size_t SingleByteToUTF8(
const char *t,
size_t l, std::string *s,
int m)
const;
384 size_t ISO8859ToUTF8(
const char *t,
size_t l, std::string *s,
int m)
const;
385 size_t UTF8ToISO2022(
const char *t,
size_t l, std::string *s,
int m)
const;
386 size_t ISO2022ToUTF8(
const char *t,
size_t l, std::string *s,
int m)
const;
387 size_t UTF8ToEUCKR(
const char *t,
size_t l, std::string *s,
int m)
const;
388 static size_t EUCKRToUTF8(
const char *t,
size_t l, std::string *s,
int m);
389 static size_t UTF8ToGB2312(
const char *t,
size_t l, std::string *s,
int m);
390 static size_t GB2312ToUTF8(
const char *t,
size_t l, std::string *s,
int m);
391 static size_t UTF8ToGB18030(
const char *t,
size_t l, std::string *s,
int m);
392 static size_t GB18030ToUTF8(
const char *t,
size_t l, std::string *s,
int m);
393 static size_t UTF8ToGBK(
const char *t,
size_t l, std::string *s,
int m);
394 static size_t GBKToUTF8(
const char *t,
size_t l, std::string *s,
int m);
395 static size_t UTF8ToBig5(
const char *t,
size_t l, std::string *s,
int m);
396 static size_t Big5ToUTF8(
const char *t,
size_t l, std::string *s,
int m);
397 static size_t UTF8ToEUCJP(
const char *t,
size_t l, std::string *s,
int m);
398 static size_t EUCJPToUTF8(
const char *t,
size_t l, std::string *s,
int m);
399 static size_t UTF8ToSJIS(
const char *t,
size_t l, std::string *s,
int m);
400 static size_t SJISToUTF8(
const char *t,
size_t l, std::string *s,
int m);
401 static size_t UTF8ToJISX(
402 int charset,
const char *t,
size_t l, std::string *s,
int m);
403 static size_t JISXToUTF8(
404 int csGL,
int csGR,
const char *t,
size_t l, std::string *s,
int m);
405 static size_t UTF8ToCP1258(
const char *t,
size_t l, std::string *s,
int m);
406 static size_t CP1258ToUTF8(
const char *t,
size_t l, std::string *s,
int m);
407 static size_t UTF8ToJISX0201(
const char *t,
size_t l, std::string *s,
int m);
409 unsigned int InitISO2022(
unsigned char G[4])
const;
410 static EscapeType EscapeCode(
const char *cp,
size_t l,
unsigned int *state);
411 unsigned char CharacterSetFromEscapeCodeJP(
const char *code,
size_t l)
const;
412 unsigned char CharacterSetFromEscapeCode(
const char *code,
size_t l)
const;
413 static unsigned char KeyFromString(
const char *name,
size_t nl);
417 static unsigned char GlobalDefault;
418 static bool GlobalOverride;
420 static const unsigned short *Table[256];
421 static const unsigned short *Reverse[256];
423 static const int NumberOfAliases;
424 static const char *
const Aliases[];
425 static const unsigned char AliasKeys[];
Character sets.
Definition: vtkDICOMCharacterSet.h:55
bool IsISO8859() const
Returns true if this uses an ISO 8859 code page.
Definition: vtkDICOMCharacterSet.h:291
bool IsISO2022() const
Returns true if ISO 2022 escape codes are used.
Definition: vtkDICOMCharacterSet.h:286
bool IsBiDirectional() const
Check for bidirectional character sets.
Definition: vtkDICOMCharacterSet.h:302
std::string ToUTF8(const char *text, size_t l, size_t *lp=nullptr) const
Convert text from this encoding to UTF-8.
const char * GetName() const
Get a name that identifies this character set.
std::string ConvertToUTF8(const char *text, size_t l) const
Obsolete method for converting to UTF8.
vtkDICOMCharacterSet(const std::string &name)
Construct a character set object from a SpecificCharacterSet value.
Definition: vtkDICOMCharacterSet.h:144
std::string ToSafeUTF8(const char *text, size_t l) const
Convert text to UTF-8 that is safe to print to the console.
std::string GetCharacterSetString() const
Generate SpecificCharacterSet code values (diagnostic only).
size_t NextBackslash(const char *text, const char *end) const
Get the offset to the next backslash, or to the end of the string.
vtkDICOMCharacterSet(int k)
Construct a character set object from a given code.
Definition: vtkDICOMCharacterSet.h:137
const char * GetDefinedTerm() const
Get the defined term (possible multi-valued) for this character set.
unsigned char GetKey() const
Get the numerical code for this character set object.
Definition: vtkDICOMCharacterSet.h:220
std::string CaseFoldedUTF8(const char *text, size_t l) const
Convert text into a form suitable for case-insensitive matching.
const char * GetMIMEName() const
Get the internet MIME name for this character set.
static void SetGlobalDefault(vtkDICOMCharacterSet cs)
Set the character set to use if SpecificCharacterSet is missing.
Definition: vtkDICOMCharacterSet.h:159
static void SetGlobalOverride(bool b)
Override the value stored in SpecificCharacterSet with the default.
Definition: vtkDICOMCharacterSet.h:170
std::string FromUTF8(const char *text, size_t l, size_t *lp=nullptr) const
Convert text from UTF-8 to this encoding.
unsigned int CountBackslashes(const char *text, size_t l) const
Count the number of backslashes in an encoded string.