CFx SDK Documentation 2024 SP0
Loading...
Searching...
No Matches
OdCharMapper.h
Go to the documentation of this file.
1
2// Copyright (C) 2002-2022, Open Design Alliance (the "Alliance").
3// All rights reserved.
4//
5// This software and its documentation and related materials are owned by
6// the Alliance. The software may only be incorporated into application
7// programs owned by members of the Alliance, subject to a signed
8// Membership Agreement and Supplemental Software License Agreement with the
9// Alliance. The structure and organization of this software are the valuable
10// trade secrets of the Alliance and its suppliers. The software is also
11// protected by copyright law and international treaty provisions. Application
12// programs incorporating this software must include the following statement
13// with their copyright notices:
14//
15// This application incorporates Open Design Alliance software pursuant to a license
16// agreement with Open Design Alliance.
17// Open Design Alliance Copyright (C) 2002-2022 by Open Design Alliance.
18// All rights reserved.
19//
20// By use of this software, its documentation or related materials, you
21// acknowledge and accept the above terms.
23
24
25
26
27#ifndef _OD_CHARMAPPER_H_
28#define _OD_CHARMAPPER_H_
29
30#include "TD_PackPush.h"
31
32#include "OdCodePage.h"
33#include "OdError.h"
34#include "OdArray.h"
35#include "IntArray.h"
36
37class OdStreamBuf;
38class OdString;
39class OdFont;
40typedef OdArray <char, OdMemoryAllocator<char> > OdAnsiCharArray;
42
43
50{
51 static OdString m_MapFile;
52private:
54public:
55// static OdResult initialize(OdStreamBuf* pIo);
56
63 static OdResult initialize(const OdString& filename);
64
75 OdCodePageId codepageId,
76 OdChar& codepageChar,
77 bool bTryToUseSystemCP = true );
78
88 OdCodePageId codepageId,
89 OdChar& codepageChar);
90
100 OdCodePageId codepageId,
101 OdChar& unicodeChar);
102
110 static bool isLeadByte(OdUInt8 testByte, OdCodePageId codepageId);
111
119 static OdResult codepageDescToId(const OdString& description, OdCodePageId& codepageId);
120
128 static OdResult codepageIdToDesc(OdCodePageId codepageId, OdString& description);
129
136
144
151 static OdUInt32 acadCpToAnsiCp(OdCodePageId acadCodePageId);
152
160
172
179 static bool isConversionSupported(OdCodePageId codepageId);
180
189 static void wideCharToMultiByte(OdCodePageId codePage, const OdChar* srcBuf, int srcSize, OdAnsiCharArray& dstBuf);
190
198 static void multiByteToWideChar(OdCodePageId codePage, const char* srcBuf, int srcSize, OdCharArray& dstBuf);
199
200 // This is actually CESU-8 encoding used in DXF (http://www.unicode.org/reports/tr26/)
209 static bool utf8ToUnicode(const char* srcBuf, int srcSize, OdCharArray& dstBuf);
210
218 static void unicodeToUtf8(const OdChar* srcBuf, int srcSize, OdAnsiCharArray& dstBuf);
219
237 static OdResult addBigFontWithIndex(const OdString& bigFont, OdInt32 cpIndex);
238
254 static OdResult addBigFontWithCodepage(const OdString& bigFont, OdCodePageId codePageId);
255
276
291 static OdCodePageId getCpByBigFont(const OdString& bigFont);
292
309 static OdInt32 getCpIndexByBigFont(const OdString& bigFont);
310
317 static double getCheckSumAnsi(OdAnsiString str);
318
325 static double getCheckSumUnicode(OdString str);
326
333 static OdString convertCIFcoding(const OdString& strText);
334
342
349 static OdAnsiString convertAlphaNumJapanese(const OdAnsiString& strText);
350
359 static bool containsSpecialSequence(OdString& str, OdFont* font, OdIntArray& ulRanges);
360
370 static OdString embedTextRawData(const OdString &msg, const OdIntArray &ulFlags, int *length = NULL, bool *raw = NULL);
371};
372
373// Surrogate pairs support
374template<class T> inline bool odIsLeadSurrogate(T chr) {
375 return (chr >= 0xD800 && chr <= 0xDFFF);
376}
377template<class T> inline bool odIsTailSurrogate(T chr) {
378 return (chr >= 0xDC00 && chr <= 0xDFFF);
379}
380template<class T1, class T2> inline T1 odToCodepoint(T1 chr, T2 chr2) {
381 return (chr << 10) + chr2 + (0x10000 - (0xD800 << 10) - 0xDC00);
382}
383template<class T> inline OdUInt32 odToCodeValue(T chr, T chr2) {
384 return ((OdUInt32)chr << 10) + chr2 + (0x10000 - (0xD800 << 10) - 0xDC00);
385}
386template<class T> inline bool odIsCodepoint(T chr) {
387 return (chr >= 0x10000 && chr <= 0x10FFFF);
388}
389template<class T> inline T odToLeadSurrogate(T chr) {
390 return ((0xD800 - (0x10000 >> 10)) + (chr >> 10));
391}
392template<class T> inline T odToTailSurrogate(T chr) {
393 return (0xDC00 + (chr & 0x3FF));
394}
395
400{
412
413#include "TD_PackPop.h"
414
415#endif
416
T odToLeadSurrogate(T chr)
Definition: OdCharMapper.h:389
T1 odToCodepoint(T1 chr, T2 chr2)
Definition: OdCharMapper.h:380
OdArray< char, OdMemoryAllocator< char > > OdAnsiCharArray
Definition: OdCharMapper.h:40
OdAsianCpIndex
Definition: OdCharMapper.h:400
@ TRADITIONAL_CHINESE_CP_INDEX
Definition: OdCharMapper.h:404
@ KOREAN_WANSUNG_CP_INDEX
Definition: OdCharMapper.h:406
@ KOREAN_JOHAB_CP_INDEX
Definition: OdCharMapper.h:408
@ SIMPLIFIED_CHINESE_CP_INDEX
Definition: OdCharMapper.h:410
@ JAPANESE_CP_INDEX
Definition: OdCharMapper.h:402
bool odIsLeadSurrogate(T chr)
Definition: OdCharMapper.h:374
OdArray< OdChar, OdMemoryAllocator< OdChar > > OdCharArray
Definition: OdCharMapper.h:41
bool odIsTailSurrogate(T chr)
Definition: OdCharMapper.h:377
T odToTailSurrogate(T chr)
Definition: OdCharMapper.h:392
OdUInt32 odToCodeValue(T chr, T chr2)
Definition: OdCharMapper.h:383
bool odIsCodepoint(T chr)
Definition: OdCharMapper.h:386
OdCodePageId
Definition: OdCodePage.h:31
unsigned int OdUInt32
unsigned short OdUInt16
int OdInt32
unsigned char OdUInt8
wchar_t OdChar
OdResult
Definition: OdResult.h:29
#define FIRSTDLL_EXPORT
Definition: RootExport.h:39
static OdUInt16 getReorderCharsetByChar(OdChar ch)
static void unicodeToUtf8(const OdChar *srcBuf, int srcSize, OdAnsiCharArray &dstBuf)
static OdCodePageId ansiCpToAcadCp(OdUInt32 ansiCodePage)
static OdResult unicodeToCodepage(OdChar sourceChar, OdCodePageId codepageId, OdChar &codepageChar, bool bTryToUseSystemCP=true)
static bool isLeadByte(OdUInt8 testByte, OdCodePageId codepageId)
static void multiByteToWideChar(OdCodePageId codePage, const char *srcBuf, int srcSize, OdCharArray &dstBuf)
static OdResult codepageDescToId(const OdString &description, OdCodePageId &codepageId)
static double getCheckSumAnsi(OdAnsiString str)
static bool containsSpecialSequence(OdString &str, OdFont *font, OdIntArray &ulRanges)
static OdResult addBigFonts(OdStreamBuf *io)
static OdCodePageId getCpByBigFont(const OdString &bigFont)
static OdString convertCIFcoding(const OdString &strText)
static void wideCharToMultiByte(OdCodePageId codePage, const OdChar *srcBuf, int srcSize, OdAnsiCharArray &dstBuf)
static OdUInt32 numValidCodepages()
static OdResult initialize(const OdString &filename)
static OdCodePageId getCodepageByCharset(OdUInt16 ansiCharacterSet)
static bool isConversionSupported(OdCodePageId codepageId)
static bool utf8ToUnicode(const char *srcBuf, int srcSize, OdCharArray &dstBuf)
static OdString embedTextRawData(const OdString &msg, const OdIntArray &ulFlags, int *length=NULL, bool *raw=NULL)
static OdResult codepageIdToDesc(OdCodePageId codepageId, OdString &description)
static OdResult unicodeToCodepage2(OdChar sourceChar, OdCodePageId codepageId, OdChar &codepageChar)
static OdInt32 getCpIndexByBigFont(const OdString &bigFont)
static double getCheckSumUnicode(OdString str)
static OdString convertAlphaNumJapanese(const OdString &strText)
static OdResult addBigFontWithCodepage(const OdString &bigFont, OdCodePageId codePageId)
static OdUInt32 acadCpToAnsiCp(OdCodePageId acadCodePageId)
static OdResult addBigFontWithIndex(const OdString &bigFont, OdInt32 cpIndex)
static OdAnsiString convertAlphaNumJapanese(const OdAnsiString &strText)
static OdResult codepageToUnicode(OdChar sourceChar, OdCodePageId codepageId, OdChar &unicodeChar)
Definition: OdFont.h:371
GLuint GLsizei GLsizei * length
Definition: gles2_ext.h:274