14 #ifndef vtkDICOMCharacterSet_h
15 #define vtkDICOMCharacterSet_h
17 #include "vtkSystemIncludes.h"
18 #include "vtkDICOMModule.h"
19 #include "vtkDICOMConfig.h"
135 this->Key = KeyFromString(name.data(), name.length()); }
137 this->Key = KeyFromString(name, nl); }
150 GlobalDefault = cs.
GetKey(); }
152 return GlobalDefault; }
161 GlobalOverride = b; }
162 static void GlobalOverrideOn() { GlobalOverride =
true; }
163 static void GlobalOverrideOff() { GlobalOverride =
false; }
164 static bool GetGlobalOverride() {
return GlobalOverride; }
182 unsigned char GetKey()
const {
return this->Key; }
195 std::string
FromUTF8(
const char *text,
size_t l,
size_t *lp=0)
const;
196 std::string FromUTF8(
const std::string& text)
const {
197 return FromUTF8(text.data(), text.length()); }
211 std::string
ToUTF8(
const char *text,
size_t l,
size_t *lp=0)
const;
212 std::string ToUTF8(
const std::string& text)
const {
213 return ToUTF8(text.data(), text.length()); }
225 std::string ToSafeUTF8(
const std::string& text)
const {
226 return ToSafeUTF8(text.data(), text.length()); }
238 std::string CaseFoldedUTF8(
const std::string& text)
const {
239 return CaseFoldedUTF8(text.data(), text.length()); }
247 return ((this->Key & ISO_2022_MAX) == (this->Key | ISO_2022));
252 return (this->Key >= ISO_IR_100 && this->Key <= X_LATIN10);
263 return (this->Key == ISO_IR_127 ||
264 this->Key == ISO_IR_138 ||
265 this->Key == X_CP1255 ||
266 this->Key == X_CP1256); }
322 ALTERNATE_CS = 0x00FF,
323 MULTIBYTE_G0 = 0x0100,
324 MULTIBYTE_G1 = 0x0200,
325 MULTIBYTE_G2 = 0x0400,
326 MULTIBYTE_G3 = 0x0800,
327 CHARSET96_GX = 0x1000,
328 CHARSET96_G1 = 0x2000,
329 CHARSET96_G2 = 0x4000,
330 CHARSET96_G3 = 0x8000
335 ISO_2022_JP_BASE = 7,
341 size_t AnyToUTF8(
const char *t,
size_t l, std::string *s,
int m)
const;
342 size_t UTF8ToSingleByte(
const char *t,
size_t l, std::string *s)
const;
343 size_t SingleByteToUTF8(
const char *t,
size_t l, std::string *s,
int m)
const;
344 size_t ISO8859ToUTF8(
const char *t,
size_t l, std::string *s,
int)
const;
345 size_t UTF8ToISO2022(
const char *t,
size_t l, std::string *s)
const;
346 size_t ISO2022ToUTF8(
const char *t,
size_t l, std::string *s,
int m)
const;
347 static size_t UTF8ToEUCKR(
const char *t,
size_t l, std::string *s);
348 static size_t EUCKRToUTF8(
const char *t,
size_t l, std::string *s,
int m);
349 static size_t UTF8ToGB2312(
const char *t,
size_t l, std::string *s);
350 static size_t GB2312ToUTF8(
const char *t,
size_t l, std::string *s,
int m);
351 static size_t UTF8ToGB18030(
const char *t,
size_t l, std::string *s);
352 static size_t GB18030ToUTF8(
const char *t,
size_t l, std::string *s,
int m);
353 static size_t UTF8ToGBK(
const char *t,
size_t l, std::string *s);
354 static size_t GBKToUTF8(
const char *t,
size_t l, std::string *s,
int m);
355 static size_t UTF8ToBig5(
const char *t,
size_t l, std::string *s);
356 static size_t Big5ToUTF8(
const char *t,
size_t l, std::string *s,
int m);
357 static size_t UTF8ToEUCJP(
const char *t,
size_t l, std::string *s);
358 static size_t EUCJPToUTF8(
const char *t,
size_t l, std::string *s,
int m);
359 static size_t UTF8ToSJIS(
const char *t,
size_t l, std::string *s);
360 static size_t SJISToUTF8(
const char *t,
size_t l, std::string *s,
int m);
361 static size_t UTF8ToJISX(
362 int charset,
const char *t,
size_t l, std::string *s);
363 static size_t JISXToUTF8(
364 int csGL,
int csGR,
const char *t,
size_t l, std::string *s,
int m);
366 static unsigned int InitISO2022(
unsigned char key,
unsigned char G[4]);
367 static EscapeType EscapeCode(
const char *cp,
size_t l,
unsigned int *state);
368 static unsigned char CharacterSetFromEscapeCode(
const char *code,
size_t l);
369 static unsigned char KeyFromString(
const char *name,
size_t nl);
373 static unsigned char GlobalDefault;
374 static bool GlobalOverride;
376 static const unsigned short *Table[256];
377 static const unsigned short *Reverse[256];
Character sets.
Definition: vtkDICOMCharacterSet.h:55
bool IsISO8859() const
Returns true if this uses an ISO 8859 code page.
Definition: vtkDICOMCharacterSet.h:251
bool IsISO2022() const
Returns true if ISO 2022 escape codes are used.
Definition: vtkDICOMCharacterSet.h:246
bool IsBiDirectional() const
Check for bidirectional character sets.
Definition: vtkDICOMCharacterSet.h:262
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:134
std::string ToUTF8(const char *text, size_t l, size_t *lp=0) const
Convert text from this encoding to UTF-8.
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:127
std::string FromUTF8(const char *text, size_t l, size_t *lp=0) const
Convert text from UTF-8 to this encoding.
unsigned char GetKey() const
Get the numerical code for this character set object.
Definition: vtkDICOMCharacterSet.h:182
std::string CaseFoldedUTF8(const char *text, size_t l) const
Convert text into a form suitable for case-insensitive matching.
static void SetGlobalDefault(vtkDICOMCharacterSet cs)
Set the character set to use if SpecificCharacterSet is missing.
Definition: vtkDICOMCharacterSet.h:149
static void SetGlobalOverride(bool b)
Override the value stored in SpecificCharacterSet with the default.
Definition: vtkDICOMCharacterSet.h:160
unsigned int CountBackslashes(const char *text, size_t l) const
Count the number of backslashes in an encoded string.