Hoyt's FORK of DemoIccMAX 2.1.17.hoyt
Documentation for Hoyt's FORK of DemoIccMAX
Loading...
Searching...
No Matches
CIccLocalizedUnicode Class Reference

Data Class: CIccLocalizedUnicode. More...

#include <IccTagBasic.h>

+ Collaboration diagram for CIccLocalizedUnicode:

Public Member Functions

 CIccLocalizedUnicode ()
 Name: CIccLocalizedUnicode::CIccLocalizedUnicode.
 
 CIccLocalizedUnicode (const CIccLocalizedUnicode &ILU)
 Name: CIccLocalizedUnicode::CIccLocalizedUnicode.
 
icUInt16NumberGetBuf () const
 
icUInt32Number GetLength () const
 
bool GetText (std::string &text)
 Name: CIccLocalizedUnicode::GetText.
 
const icCharGetUtf8 (icChar *szBuf, icUInt32Number nBufSize)
 Name: CIccLocalizedUnicode::GetUtf8.
 
icUInt32Number GetUtf8Size ()
 Name: CIccLocalizedUnicode::GetUtf8Size.
 
CIccLocalizedUnicodeoperator= (const CIccLocalizedUnicode &UnicodeText)
 Name: CIccLocalizedUnicode::operator=.
 
const icCharoperator= (const icChar *szText)
 
const icUInt16Numberoperator= (const icUInt16Number *sszText)
 
const icUInt32Numberoperator= (const icUInt32Number *sszText)
 
bool SetSize (icUInt32Number)
 Name: CIccLocalizedUnicode::SetSize.
 
bool SetText (const icChar *szText, icLanguageCode nLanguageCode=icLanguageCodeEnglish, icCountryCode nRegionCode=icCountryCodeUSA)
 Name: CIccLocalizedUnicode::SetText.
 
bool SetText (const icUInt16Number *sszUnicode16Text, icLanguageCode nLanguageCode=icLanguageCodeEnglish, icCountryCode nRegionCode=icCountryCodeUSA)
 Name: CIccLocalizedUnicode::SetText.
 
bool SetText (const icUInt32Number *sszUnicode32Text, icLanguageCode nLanguageCode=icLanguageCodeEnglish, icCountryCode nRegionCode=icCountryCodeUSA)
 Name: CIccLocalizedUnicode::SetText.
 
virtual ~CIccLocalizedUnicode ()
 Name: CIccLocalizedUnicode::~CIccLocalizedUnicode.
 

Public Attributes

icCountryCode m_nCountryCode
 
icLanguageCode m_nLanguageCode
 

Protected Attributes

icUInt32Number m_nLength
 
icUInt16Numberm_pBuf
 

Detailed Description

Data Class: CIccLocalizedUnicode.

Purpose: Implementation of a unicode string with language and region identifiers.

Definition at line 1168 of file IccTagBasic.h.

Constructor & Destructor Documentation

◆ CIccLocalizedUnicode() [1/2]

CIccLocalizedUnicode::CIccLocalizedUnicode ( )

Name: CIccLocalizedUnicode::CIccLocalizedUnicode.

Purpose: Constructor

Definition at line 6903 of file IccTagBasic.cpp.

6904{
6905 m_pBuf = (icUInt16Number*)malloc(1*sizeof(icUInt16Number));
6906 *m_pBuf = 0;
6907 m_nLength = 0;
6908}
icUInt32Number m_nLength
icUInt16Number * m_pBuf
unsigned short icUInt16Number

◆ CIccLocalizedUnicode() [2/2]

CIccLocalizedUnicode::CIccLocalizedUnicode ( const CIccLocalizedUnicode & ILU)

Name: CIccLocalizedUnicode::CIccLocalizedUnicode.

Purpose: Copy Constructor

Args: ILU = The CIccLocalizedUnicode object to be copied

Definition at line 6921 of file IccTagBasic.cpp.

6922{
6923 m_nLength = ILU.GetLength();
6924 m_pBuf = (icUInt16Number*)malloc((m_nLength+1) * sizeof(icUInt16Number));
6925 if (m_nLength)
6926 memcpy(m_pBuf, ILU.GetBuf(), m_nLength*sizeof(icUInt16Number));
6927 m_pBuf[m_nLength] = 0;
6930}
icLanguageCode m_nLanguageCode
icUInt16Number * GetBuf() const
icUInt32Number GetLength() const
icCountryCode m_nCountryCode

References GetBuf(), GetLength(), m_nCountryCode, and m_nLanguageCode.

+ Here is the call graph for this function:

◆ ~CIccLocalizedUnicode()

CIccLocalizedUnicode::~CIccLocalizedUnicode ( )
virtual

Name: CIccLocalizedUnicode::~CIccLocalizedUnicode.

Purpose: Destructor

Definition at line 6966 of file IccTagBasic.cpp.

6967{
6968 if (m_pBuf)
6969 free(m_pBuf);
6970}

Member Function Documentation

◆ GetBuf()

icUInt16Number * CIccLocalizedUnicode::GetBuf ( ) const
inline

Definition at line 1177 of file IccTagBasic.h.

1177{ return m_pBuf; }

Referenced by CIccLocalizedUnicode(), operator=(), and CIccTagMultiLocalizedUnicode::Read().

+ Here is the caller graph for this function:

◆ GetLength()

icUInt32Number CIccLocalizedUnicode::GetLength ( ) const
inline

Definition at line 1176 of file IccTagBasic.h.

1176{ return m_nLength; }

Referenced by CIccLocalizedUnicode(), and operator=().

+ Here is the caller graph for this function:

◆ GetText()

bool CIccLocalizedUnicode::GetText ( std::string & sText)

Name: CIccLocalizedUnicode::GetText.

Purpose: Gets text as a UTF-8 string

Args: sText - string to put results in

Definition at line 7032 of file IccTagBasic.cpp.

7033{
7034 sText.clear();
7035
7036 icUInt16Number* str = m_pBuf;
7037 while (*str) {
7038 icUInt32Number code32 = 0x0;
7039
7040 //UTF-16 to UTF-32
7041
7042 if (*str <= 0xD7FF) {
7043 code32 = *str;
7044 str++;
7045 }
7046 else if (*str <= 0xDBFF) {
7047 icUInt16Number high = (*str - 0xD800) * 0x400;
7048 icUInt16Number low = *(str + 1) - 0xDC00;
7049 code32 = (low | high) + 0x10000;
7050 str += 2;
7051 }
7052
7053 //UTF-32 to UTF-8 -------
7054
7055 if (code32 <= 0x007F) {
7056 sText += (unsigned char)code32;
7057 }
7058 else if (code32 <= 0x07FF) {
7059 sText += (unsigned char)(((code32 >> 6) & 0x1F) | 0xC0);
7060 sText += (unsigned char)((code32 & 0x3F) | 0x80);
7061 }
7062 else if (code32 <= 0xFFFF) {
7063 sText += (unsigned char)(((code32 >> 12) & 0x0F) | 0xE0);
7064 sText += (unsigned char)(((code32 >> 6) & 0x3F) | 0x80);
7065 sText += (unsigned char)(((code32) & 0x3F) | 0x80);
7066 }
7067 else if (code32 <= 0x10FFFF) {
7068 sText += (unsigned char)(((code32 >> 18) & 0x07) | 0xF0);
7069 sText += (unsigned char)(((code32 >> 12) & 0x3F) | 0x80);
7070 sText += (unsigned char)(((code32 >> 6) & 0x3F) | 0x80);
7071 sText += (unsigned char)(((code32) & 0x3F) | 0x80);
7072 }
7073 }
7074
7075 return true;
7076}
unsigned int icUInt32Number

Referenced by icGetTagText().

+ Here is the caller graph for this function:

◆ GetUtf8()

const icChar * CIccLocalizedUnicode::GetUtf8 ( icChar * szBuf,
icUInt32Number nBufSize )

Name: CIccLocalizedUnicode::GetUtf8.

Purpose: Extracts the ANSI data buffer (from UTF-16BE)

Args: szBuf = pointer where the returned string buffer is to be stored nBufSize = size of the buffer to be extracted

Return: Pointer to the ANSI data string

Definition at line 7002 of file IccTagBasic.cpp.

7003{
7004 if (!szBuf || !nBufSize)
7005 return NULL;
7006
7007 std::string str;
7008 GetText(str);
7009
7010 if (nBufSize - 1 < str.size()) {
7011 memcpy(szBuf, str.c_str(), nBufSize - 1);
7012 szBuf[nBufSize] = 0;
7013 }
7014 else {
7015 strcpy(szBuf, str.c_str());
7016 }
7017
7018 return szBuf;
7019}
bool GetText(std::string &text)
Name: CIccLocalizedUnicode::GetText.

◆ GetUtf8Size()

icUInt32Number CIccLocalizedUnicode::GetUtf8Size ( )

Name: CIccLocalizedUnicode::GetUtf8Size.

Purpose: Returns the size of the ANSI data buffer

Definition at line 6980 of file IccTagBasic.cpp.

6981{
6982 std::string str;
6983 GetText(str);
6984
6985 return (icUInt32Number)str.size()+1;
6986}

◆ operator=() [1/4]

CIccLocalizedUnicode & CIccLocalizedUnicode::operator= ( const CIccLocalizedUnicode & UnicodeText)

Name: CIccLocalizedUnicode::operator=.

Purpose: Copy Operator

Args: UnicodeText = The CIccLocalizedUnicode object to be copied

Definition at line 6943 of file IccTagBasic.cpp.

6944{
6945 if (&UnicodeText == this)
6946 return *this;
6947
6948 if (SetSize(UnicodeText.GetLength())) {
6949 memcpy(m_pBuf, UnicodeText.GetBuf(), m_nLength*sizeof(icUInt16Number));
6950 }
6951 m_nLanguageCode = UnicodeText.m_nLanguageCode;
6952 m_nCountryCode = UnicodeText.m_nCountryCode;
6953
6954 return *this;
6955}
bool SetSize(icUInt32Number)
Name: CIccLocalizedUnicode::SetSize.

References GetBuf(), GetLength(), m_nCountryCode, and m_nLanguageCode.

+ Here is the call graph for this function:

◆ operator=() [2/4]

const icChar * CIccLocalizedUnicode::operator= ( const icChar * szText)
inline

Definition at line 1196 of file IccTagBasic.h.

1196{ SetText(szText); return szText; }
bool SetText(const icChar *szText, icLanguageCode nLanguageCode=icLanguageCodeEnglish, icCountryCode nRegionCode=icCountryCodeUSA)
Name: CIccLocalizedUnicode::SetText.

◆ operator=() [3/4]

const icUInt16Number * CIccLocalizedUnicode::operator= ( const icUInt16Number * sszText)
inline

Definition at line 1197 of file IccTagBasic.h.

1197{ SetText(sszText); return sszText; }

◆ operator=() [4/4]

const icUInt32Number * CIccLocalizedUnicode::operator= ( const icUInt32Number * sszText)
inline

Definition at line 1198 of file IccTagBasic.h.

1198{ SetText(sszText); return sszText; }

◆ SetSize()

bool CIccLocalizedUnicode::SetSize ( icUInt32Number nSize)

Name: CIccLocalizedUnicode::SetSize.

Purpose: Sets the size of the string buffer.

Args: nSize - length of the string

Definition at line 7090 of file IccTagBasic.cpp.

7091{
7092 if (nSize == m_nLength)
7093 return true;
7094
7095 m_pBuf = (icUInt16Number*)icRealloc(m_pBuf, (nSize+1)*sizeof(icUInt16Number));
7096
7097 if (!m_pBuf) {
7098 m_nLength = 0;
7099 return false;
7100 }
7101
7102 m_nLength = nSize;
7103
7104 m_pBuf[nSize]=0;
7105
7106 return true;
7107}
void * icRealloc(void *ptr, size_t size)
Name: icRealloc.
Definition IccUtil.cpp:111

References icRealloc().

Referenced by CIccTagMultiLocalizedUnicode::Read().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SetText() [1/3]

bool CIccLocalizedUnicode::SetText ( const icChar * szText,
icLanguageCode nLanguageCode = icLanguageCodeEnglish,
icCountryCode nRegionCode = icCountryCodeUSA )

Name: CIccLocalizedUnicode::SetText.

Purpose: Allows text data associated with the tag to be set.

Args: szText = zero terminated utf8 string to put in tag, nLanguageCode = the language code type as defined by icLanguageCode, nRegionCode = the region code type as defined by icCountryCode

Definition at line 7121 of file IccTagBasic.cpp.

7124{
7125 //first convert utf8 to unicode
7126 std::vector<unsigned long> unicode;
7127 size_t i = 0;
7128 while (szText[i])
7129 {
7130 unsigned long uni;
7131 size_t todo;
7132 bool error = false;
7133 unsigned char ch = szText[i++];
7134 if (ch <= 0x7F)
7135 {
7136 uni = ch;
7137 todo = 0;
7138 }
7139 else if (ch <= 0xBF)
7140 {
7141 //not a UTF-8 string so use question mark
7142 uni = '?';
7143 todo = 0;
7144 }
7145 else if (ch <= 0xDF)
7146 {
7147 uni = ch & 0x1F;
7148 todo = 1;
7149 }
7150 else if (ch <= 0xEF)
7151 {
7152 uni = ch & 0x0F;
7153 todo = 2;
7154 }
7155 else if (ch <= 0xF7)
7156 {
7157 uni = ch & 0x07;
7158 todo = 3;
7159 }
7160 else
7161 {
7162 //not a UTF-8 string so use question mark
7163 uni = '?';
7164 todo = 0;;
7165 }
7166 for (size_t j = 0; j < todo; ++j)
7167 {
7168 if (!szText[i]) {
7169 uni = '?';
7170 break;
7171 }
7172 else {
7173 unsigned char ch = szText[i];
7174 if (ch < 0x80 || ch > 0xBF) {
7175 //not a UTF-8 string so use question mark
7176 uni = '?';
7177 break;
7178 }
7179 else {
7180 uni <<= 6;
7181 uni += ch & 0x3F;
7182 }
7183 }
7184 }
7185 if (uni >= 0xD800 && uni <= 0xDFFF) {
7186 //not a UTF-8 string so use question mark
7187 uni = '?';
7188 }
7189 else if (uni > 0x10FFFF) {
7190 //not a UTF-8 string so use question mark
7191 uni = '?';
7192 }
7193 unicode.push_back(uni);
7194 }
7195
7196 //now convert unicode to utf16
7197 std::vector<unsigned short> utf16;
7198 for (i = 0; i < unicode.size(); ++i)
7199 {
7200 unsigned long uni = unicode[i];
7201 if (uni <= 0xFFFF)
7202 {
7203 utf16.push_back((unsigned short)uni);
7204 }
7205 else
7206 {
7207 uni -= 0x10000;
7208 utf16.push_back((unsigned short)((uni >> 10) + 0xD800));
7209 utf16.push_back((unsigned short)((uni & 0x3FF) + 0xDC00));
7210 }
7211 }
7212
7213 icUInt16Number *pBuf;
7214
7215 size_t len = utf16.size();
7216 if (!SetSize((icUInt32Number)len+1))
7217 return false;
7218
7219 pBuf = m_pBuf;
7220 for (i=0; i<len; i++) {
7221 *pBuf++ = utf16[i];
7222 }
7223 *pBuf = 0;
7224
7225 m_nLanguageCode = nLanguageCode;
7226 m_nCountryCode = nRegionCode;
7227
7228 return true;
7229}

Referenced by CIccTagMultiLocalizedUnicode::SetText(), CIccTagMultiLocalizedUnicode::SetText(), and CIccTagMultiLocalizedUnicode::SetText().

+ Here is the caller graph for this function:

◆ SetText() [2/3]

bool CIccLocalizedUnicode::SetText ( const icUInt16Number * sszUnicode16Text,
icLanguageCode nLanguageCode = icLanguageCodeEnglish,
icCountryCode nRegionCode = icCountryCodeUSA )

Name: CIccLocalizedUnicode::SetText.

Purpose: Allows text data associated with the tag to be set.

Args: sszUnicode16Text = Unicode16 text to be set, nLanguageCode = the language code type as defined by icLanguageCode, nRegionCode = the region code type as defined by icCountryCode

Definition at line 7243 of file IccTagBasic.cpp.

7246{
7247 const icUInt16Number *pBuf=sszUnicode16Text;
7248 int len;
7249
7250 for (len=0; *pBuf; len++, pBuf++);
7251
7252 if (!SetSize(len))
7253 return false;
7254 memcpy(m_pBuf, sszUnicode16Text, (len+1)*sizeof(icUInt16Number));
7255
7256 m_nLanguageCode = nLanguageCode;
7257 m_nCountryCode = nRegionCode;
7258
7259 return true;
7260}

◆ SetText() [3/3]

bool CIccLocalizedUnicode::SetText ( const icUInt32Number * sszUnicode32Text,
icLanguageCode nLanguageCode = icLanguageCodeEnglish,
icCountryCode nRegionCode = icCountryCodeUSA )

Name: CIccLocalizedUnicode::SetText.

Purpose: Allows text data associated with the tag to be set.

Args: sszUnicode32Text = Unicode32 text to be set, nLanguageCode = the language code type as defined by icLanguageCode, nRegionCode = the region code type as defined by icCountryCode

Definition at line 7274 of file IccTagBasic.cpp.

7277{
7278 const icUInt32Number *pBuf=sszUnicode32Text;
7279 int len;
7280
7281 for (len=0; *pBuf; len++, pBuf++);
7282 if (*pBuf)
7283 pBuf--;
7284
7285 if (!SetSize(len*2))
7286 return false;
7287
7288 const icUInt32Number *srcStart = sszUnicode32Text;
7289 icUInt16Number *dstStart = m_pBuf;
7290 icConvertUTF32toUTF16(&srcStart, &srcStart[len], &dstStart, &dstStart[len*2], lenientConversion);
7291
7292 *dstStart=0;
7293 if (!SetSize((icUInt32Number)(dstStart - m_pBuf)))
7294 return false;
7295
7296 m_nLanguageCode = nLanguageCode;
7297 m_nCountryCode = nRegionCode;
7298
7299 return true;
7300}
icUtfConversionResult icConvertUTF32toUTF16(const UTF32 **sourceStart, const UTF32 *sourceEnd, UTF16 **targetStart, UTF16 *targetEnd, icUtfConversionFlags flags)
@ lenientConversion

References icConvertUTF32toUTF16(), and lenientConversion.

+ Here is the call graph for this function:

Member Data Documentation

◆ m_nCountryCode

icCountryCode CIccLocalizedUnicode::m_nCountryCode

◆ m_nLanguageCode

icLanguageCode CIccLocalizedUnicode::m_nLanguageCode

◆ m_nLength

icUInt32Number CIccLocalizedUnicode::m_nLength
protected

Definition at line 1205 of file IccTagBasic.h.

◆ m_pBuf

icUInt16Number* CIccLocalizedUnicode::m_pBuf
protected

Definition at line 1207 of file IccTagBasic.h.


The documentation for this class was generated from the following files: