mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-21 06:53:53 +00:00
Merge branch 'touft8_const' into 'master'
Constify a bit to_utf8.cpp and add a call to memcpy instead of doing it by hand See merge request OpenMW/openmw!894
This commit is contained in:
commit
d9e938f0d6
4 changed files with 16 additions and 16 deletions
|
@ -45,7 +45,7 @@ void writeMissing(bool last)
|
||||||
int write_table(const std::string &charset, const std::string &tableName)
|
int write_table(const std::string &charset, const std::string &tableName)
|
||||||
{
|
{
|
||||||
// Write table header
|
// Write table header
|
||||||
std::cout << "static signed char " << tableName << "[] =\n{\n";
|
std::cout << "const static signed char " << tableName << "[] =\n{\n";
|
||||||
|
|
||||||
// Open conversion system
|
// Open conversion system
|
||||||
iconv_t cd = iconv_open ("UTF-8", charset.c_str());
|
iconv_t cd = iconv_open ("UTF-8", charset.c_str());
|
||||||
|
|
|
@ -8,7 +8,7 @@ namespace ToUTF8
|
||||||
/// Central European and Eastern European languages that use Latin script,
|
/// Central European and Eastern European languages that use Latin script,
|
||||||
/// such as Polish, Czech, Slovak, Hungarian, Slovene, Bosnian, Croatian,
|
/// such as Polish, Czech, Slovak, Hungarian, Slovene, Bosnian, Croatian,
|
||||||
/// Serbian (Latin script), Romanian and Albanian.
|
/// Serbian (Latin script), Romanian and Albanian.
|
||||||
static signed char windows_1250[] =
|
const static signed char windows_1250[] =
|
||||||
{
|
{
|
||||||
1, 0, 0, 0, 0, 0,
|
1, 0, 0, 0, 0, 0,
|
||||||
1, 1, 0, 0, 0, 0,
|
1, 1, 0, 0, 0, 0,
|
||||||
|
@ -270,7 +270,7 @@ static signed char windows_1250[] =
|
||||||
|
|
||||||
/// Cyrillic alphabet such as Russian, Bulgarian, Serbian Cyrillic
|
/// Cyrillic alphabet such as Russian, Bulgarian, Serbian Cyrillic
|
||||||
/// and other languages
|
/// and other languages
|
||||||
static signed char windows_1251[] =
|
const static signed char windows_1251[] =
|
||||||
{
|
{
|
||||||
1, 0, 0, 0, 0, 0,
|
1, 0, 0, 0, 0, 0,
|
||||||
1, 1, 0, 0, 0, 0,
|
1, 1, 0, 0, 0, 0,
|
||||||
|
@ -531,7 +531,7 @@ static signed char windows_1251[] =
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Latin alphabet used by English and some other Western languages
|
/// Latin alphabet used by English and some other Western languages
|
||||||
static signed char windows_1252[] =
|
const static signed char windows_1252[] =
|
||||||
{
|
{
|
||||||
1, 0, 0, 0, 0, 0,
|
1, 0, 0, 0, 0, 0,
|
||||||
1, 1, 0, 0, 0, 0,
|
1, 1, 0, 0, 0, 0,
|
||||||
|
@ -790,7 +790,7 @@ static signed char windows_1252[] =
|
||||||
2, -61, -66, 0, 0, 0,
|
2, -61, -66, 0, 0, 0,
|
||||||
2, -61, -65, 0, 0, 0
|
2, -61, -65, 0, 0, 0
|
||||||
};
|
};
|
||||||
static signed char cp437[] =
|
const static signed char cp437[] =
|
||||||
{
|
{
|
||||||
1, 0, 0, 0, 0, 0,
|
1, 0, 0, 0, 0, 0,
|
||||||
1, 1, 0, 0, 0, 0,
|
1, 1, 0, 0, 0, 0,
|
||||||
|
|
|
@ -182,7 +182,7 @@ void Utf8Encoder::resize(size_t size)
|
||||||
is the case, then the ascii parameter is set to true, and the
|
is the case, then the ascii parameter is set to true, and the
|
||||||
caller can optimize for this case.
|
caller can optimize for this case.
|
||||||
*/
|
*/
|
||||||
size_t Utf8Encoder::getLength(const char* input, bool &ascii)
|
size_t Utf8Encoder::getLength(const char* input, bool &ascii) const
|
||||||
{
|
{
|
||||||
ascii = true;
|
ascii = true;
|
||||||
size_t len = 0;
|
size_t len = 0;
|
||||||
|
@ -214,7 +214,7 @@ size_t Utf8Encoder::getLength(const char* input, bool &ascii)
|
||||||
|
|
||||||
// Translate one character 'ch' using the translation array 'arr', and
|
// Translate one character 'ch' using the translation array 'arr', and
|
||||||
// advance the output pointer accordingly.
|
// advance the output pointer accordingly.
|
||||||
void Utf8Encoder::copyFromArray(unsigned char ch, char* &out)
|
void Utf8Encoder::copyFromArray(unsigned char ch, char* &out) const
|
||||||
{
|
{
|
||||||
// Optimize for ASCII values
|
// Optimize for ASCII values
|
||||||
if (ch < 128)
|
if (ch < 128)
|
||||||
|
@ -225,11 +225,11 @@ void Utf8Encoder::copyFromArray(unsigned char ch, char* &out)
|
||||||
|
|
||||||
const signed char *in = translationArray + ch*6;
|
const signed char *in = translationArray + ch*6;
|
||||||
int len = *(in++);
|
int len = *(in++);
|
||||||
for (int i=0; i<len; i++)
|
memcpy(out, in, len);
|
||||||
*(out++) = *(in++);
|
out += len;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t Utf8Encoder::getLength2(const char* input, bool &ascii)
|
size_t Utf8Encoder::getLength2(const char* input, bool &ascii) const
|
||||||
{
|
{
|
||||||
ascii = true;
|
ascii = true;
|
||||||
size_t len = 0;
|
size_t len = 0;
|
||||||
|
@ -273,7 +273,7 @@ size_t Utf8Encoder::getLength2(const char* input, bool &ascii)
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Utf8Encoder::copyFromArray2(const char*& chp, char* &out)
|
void Utf8Encoder::copyFromArray2(const char*& chp, char* &out) const
|
||||||
{
|
{
|
||||||
unsigned char ch = *(chp++);
|
unsigned char ch = *(chp++);
|
||||||
// Optimize for ASCII values
|
// Optimize for ASCII values
|
||||||
|
|
|
@ -42,13 +42,13 @@ namespace ToUTF8
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void resize(size_t size);
|
void resize(size_t size);
|
||||||
size_t getLength(const char* input, bool &ascii);
|
size_t getLength(const char* input, bool &ascii) const;
|
||||||
void copyFromArray(unsigned char chp, char* &out);
|
void copyFromArray(unsigned char chp, char* &out) const;
|
||||||
size_t getLength2(const char* input, bool &ascii);
|
size_t getLength2(const char* input, bool &ascii) const;
|
||||||
void copyFromArray2(const char*& chp, char* &out);
|
void copyFromArray2(const char*& chp, char* &out) const;
|
||||||
|
|
||||||
std::vector<char> mOutput;
|
std::vector<char> mOutput;
|
||||||
signed char* translationArray;
|
const signed char* translationArray;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue