X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Finternal%2Ftext%2Fcharacter-set-conversion.cpp;h=d79fbc38eeb21e31cfae2b7991a065917feaab27;hp=b1b9993b3c5e06f74cdc5ce7024c863d15e908c5;hb=baef46c4babda42017ab2d5fbd362ae9e11be95b;hpb=659d0ae8e8c828cb46fad7448b37ff9b7062819d diff --git a/dali-toolkit/internal/text/character-set-conversion.cpp b/dali-toolkit/internal/text/character-set-conversion.cpp index b1b9993..d79fbc3 100644 --- a/dali-toolkit/internal/text/character-set-conversion.cpp +++ b/dali-toolkit/internal/text/character-set-conversion.cpp @@ -24,6 +24,9 @@ namespace Dali namespace Toolkit { +namespace Text +{ + namespace { const static uint8_t U1 = 1u; @@ -66,8 +69,16 @@ namespace U0, U0, U0, U0, // Non valid. U0, U0, U0, U0, // Non valid. }; + + const uint8_t CR = 0xd; + const uint8_t LF = 0xa; } // namespace +uint8_t GetUtf8Length( uint8_t utf8LeadByte ) +{ + return UTF8_LENGTH[utf8LeadByte]; +} + uint32_t GetNumberOfUtf8Characters( const uint8_t* const utf8, uint32_t length ) { uint32_t numberOfCharacters = 0u; @@ -127,8 +138,26 @@ uint32_t Utf8ToUtf32( const uint8_t* const utf8, uint32_t length, uint32_t* utf3 { case U1: { - *utf32++ = leadByte; - begin++; + if( CR == leadByte ) + { + // Replace CR+LF or CR by LF + *utf32++ = LF; + + // Look ahead if the next one is a LF. + ++begin; + if( begin < end ) + { + if( LF == *begin ) + { + ++begin; + } + } + } + else + { + *utf32++ = leadByte; + begin++; + } break; } @@ -167,6 +196,13 @@ uint32_t Utf8ToUtf32( const uint8_t* const utf8, uint32_t length, uint32_t* utf3 code |= *begin++ & 0x3fu; break; } + + case U0: // Invalid case + { + begin++; + *utf32++ = 0x20; // Use white space + break; + } } } @@ -222,6 +258,8 @@ void Utf32ToUtf8( const uint32_t* const utf32, uint32_t numberOfCharacters, std: Utf32ToUtf8( utf32, numberOfCharacters, reinterpret_cast(&utf8[0]) ); } +} // namespace Text + } // namespace Toolkit } // namespace Dali