TouchGFX + 0/4 examples
CodeScope will show references to touchgfx::Unicode from the following samples and libraries:
Examples
STM32469I-Discovery
Demonstrations
STM32469I_EVAL
Demonstrations
STM324x9I_EVAL
Demonstrations
STM32F429I-Discovery
Demonstrations
 
Symbols
loading...
Files
loading...

touchgfx::Unicode class

@class Unicode Unicode.hpp touchgfx/Unicode.hpp This class provides simple helper functions for working with 16-bit strings.

Syntax

class Unicode { public:     typedef uint16_t UnicodeChar;     static const UnicodeChar EMPTY[1];       static uint16_t strlen(const UnicodeChar* str);     static uint16_t strlen(const char* str);     static uint16_t strncpy(UnicodeChar* RESTRICT dst, const UnicodeChar* RESTRICT src, uint16_t maxchars);     static uint16_t strncpy(UnicodeChar* RESTRICT dst, const char* RESTRICT src, uint16_t maxchars);     static void itoa(int32_t value, UnicodeChar* buffer, uint16_t bufferSize, int radix);     static void utoa(uint32_t value, UnicodeChar* buffer, uint16_t bufferSize, int radix);     static int atoi(const UnicodeChar* s);     static UnicodeChar* snprintf(UnicodeChar* dst, uint16_t dstSize, const UnicodeChar* format, ...);     static UnicodeChar* vsnprintf(UnicodeChar* dst, uint16_t dstSize, const UnicodeChar* format, va_list pArg);     static UnicodeChar* snprintf(UnicodeChar* dst, uint16_t dstSize, const char* format, ...);     static UnicodeChar* vsnprintf(UnicodeChar* dst, uint16_t dstSize, const char* format, va_list pArg);     static UnicodeChar* snprintfFloats(UnicodeChar* dst, uint16_t dstSize, const UnicodeChar* format, const float* values);     static UnicodeChar* snprintfFloat(UnicodeChar* dst, uint16_t dstSize, const UnicodeChar* format, const float value)     {         return snprintfFloats(dst, dstSize, format, &value);     }     static UnicodeChar* snprintfFloats(UnicodeChar* dst, uint16_t dstSize, const char* format, const float* values);     static UnicodeChar* snprintfFloat(UnicodeChar* dst, uint16_t dstSize, const char* format, const float value)     {         return snprintfFloats(dst, dstSize, format, &value);     }     static int strncmp(const UnicodeChar* RESTRICT str1, const UnicodeChar* RESTRICT str2, uint16_t maxchars);     static int strncmp_ignore_white_spaces(const UnicodeChar* RESTRICT str1, const UnicodeChar* RESTRICT str2, uint16_t maxchars);     static uint16_t fromUTF8(const uint8_t* utf8, UnicodeChar* dst, uint16_t maxchars);     static uint16_t toUTF8(const UnicodeChar* unicode, uint8_t* utf8, uint16_t maxbytes); private:     static void composeString(const UnicodeChar*& bufptr, const UnicodeChar sign, const UnicodeChar* format, bool hasPrecision, bool zeroPrefix, int precision, bool hasWidth, int width, bool alignLeft, int& charNumber, uint16_t dstSize, UnicodeChar* dst);     static void parseFlagsAndPrecision(const UnicodeChar*& format, UnicodeChar& sign, bool& alignLeft, bool& forceDecimalPoint, bool& zeroPrefix, bool& hasWidth, int& width, bool& hasPrecision, int& precision);     static const UnicodeChar* skip_white_spaces(const UnicodeChar* str); };

Fields

EMPTY

No summary provided. Read more...

Methods

snprintfFloat()

@fn static UnicodeChar* Unicode::snprintfFloat(UnicodeChar* dst, uint16_t dstSize, const char* format, const float value) Variant of snprintf. Variant of snprintf for one float only. The number format supports only one \%f with flags/modifiers. The following is supported: %[flags][width][.precision]f Where flags can be:
'-': left justify the field (see width). '+': force sign. ' ': insert space if value is positive. '\#': insert decimal point even if there are not decimals. '0': left pad with zeros instead of spaces (see width).
Where width is the desired width of the output. If the value is larger, more characters may be generated, but not more than the parameter dstSize. Where precision is the number of number of digits after the decimal point, default is 3. Use "%.f" to not generate any numbers after the decimal point. \code{.cpp} Unicode::UnicodeChar buffer[20]; Unicode::snprintfFloat(buffer, 20, "%6.4f", 3.14159f); // buffer="3.1416" Unicode::snprintfFloat(buffer, 20, "%#6.f", 3.14159f); // buffer=" 3." Unicode::snprintfFloat(buffer, 20, "%6f", 3.14159f); // buffer=" 3.142" Unicode::snprintfFloat(buffer, 20, "%+06.f", 3.14159f); // buffer="+00003" \endcode If more control over the output is needed, see snprintfFloats which can have more than a single "%f" in the string and also supports "*" in place of a number. @warning The format string is internally copied from at char* to a UnicodeChar*. This buffer has a limit of 63 characters, so if the format is longer than 63 characters, the caller must do this copying to prevent an assert from triggering: \code{.cpp} touchgfx::Unicode::UnicodeChar tmpfmt[200]; touchgfx::Unicode::strncpy(tmpfmt, "Very, very, very, very, very, very, very, very, very long format %f", 200); touchgfx::Unicode::snprintfFloats(dst, dstSize, tmpfmt, values); \endcode @see snprintf, snprintfFloats. Read more...

strncmp()

@fn static int Unicode::strncmp(const UnicodeChar* RESTRICT str1, const UnicodeChar* RESTRICT str2, uint16_t maxchars); Compares up to maxchars characters of the string str1 to those of the string str2. Compares up to maxchars characters of the string str1 to those of the string str2. This function starts comparing the first character of each string. If they are equal to each other, it continues with the following pairs until the characters differ, until a terminating null-character is reached, or until maxchars characters match in both strings, whichever happens first. Read more...

strncmp_ignore_white_spaces()

@fn static int Unicode::strncmp_ignore_white_spaces(const UnicodeChar* RESTRICT str1, const UnicodeChar* RESTRICT str2, uint16_t maxchars); Like strncmp except that ignore any spaces in the two strings. Like strncmp except that ignore any spaces in the two strings. Read more...

fromUTF8()

@fn static uint16_t Unicode::fromUTF8(const uint8_t* utf8, UnicodeChar* dst, uint16_t maxchars); Convert a string from utf8 to unicode. Convert a string from utf8 to unicode. The conversion stops if there is no more room in the destination or if the terminating zero character has been converted. Read more...

toUTF8()

@fn static uint16_t Unicode::toUTF8(const UnicodeChar *unicode, uint8_t* utf8, uint16_t maxbytes); Converts a string from unicode to utf8. Converts a string from unicode to utf8. The conversion stops if there is no more room in the destination or if the terminating zero character has been converted. U+10000 through U+10FFFF are skipped. Read more...

skip_white_spaces()

No summary provided. Read more...

composeString()

No summary provided. Read more...

parseFlagsAndPrecision()

No summary provided. Read more...

vsnprintf()

@fn static UnicodeChar* Unicode::vsnprintf(UnicodeChar* dst, uint16_t dstSize, const char* format, va_list pArg); Variant of snprintf. Variant of snprintf. See snprintf for details. @see snprintf. Read more...

snprintfFloats()

@fn static UnicodeChar* Unicode::snprintfFloats(UnicodeChar* dst, uint16_t dstSize, const UnicodeChar* format, const float* values); Variant of snprintf for floats only. Variant of snprintf for floats only. The format supports several \%f with flags/modifiers. The following is supported: %[flags][width][.precision]f Where flags can be:
'-': left justify the field (see width). '+': force sign. ' ': insert space if value is positive '\#': insert decimal point even if there are not decimals '0': left pad with zeros instead of spaces (see width)
Where width is the desired width of the output. If the value is larger, more characters may be generated, but not more than the parameter dstSize. If width is '*' the actual width is read from the list of values passed to this function. Where precision is the number of number of digits after the decimal point, default is 3. Use "%.f" to not generate any numbers after the decimal point. If precision is '*' the actual precision is read from the list of values passed to this function. \code{.cpp} float param1[3] = { 6.0f, 4.0f, 3.14159f }; Unicode::snprintfFloats(buffer, 20, "%*.*f", param1); // buffer="3.1416" float param2[2] = { 3.14159f, -123.4f }; Unicode::snprintfFloats(buffer, 20, "%f %f", param2); // buffer="3.142 -123.400" \endcode @see snprintf, snprintfFloat. Read more...

snprintfFloat()

@fn static UnicodeChar* Unicode::snprintfFloat(UnicodeChar* dst, uint16_t dstSize, const char* format, const float value) Variant of snprintf. Variant of snprintf for one float only. The number format supports only one \%f with flags/modifiers. The following is supported: %[flags][width][.precision]f Where flags can be:
'-': left justify the field (see width). '+': force sign. ' ': insert space if value is positive. '\#': insert decimal point even if there are not decimals. '0': left pad with zeros instead of spaces (see width).
Where width is the desired width of the output. If the value is larger, more characters may be generated, but not more than the parameter dstSize. Where precision is the number of number of digits after the decimal point, default is 3. Use "%.f" to not generate any numbers after the decimal point. \code{.cpp} Unicode::UnicodeChar buffer[20]; Unicode::snprintfFloat(buffer, 20, "%6.4f", 3.14159f); // buffer="3.1416" Unicode::snprintfFloat(buffer, 20, "%#6.f", 3.14159f); // buffer=" 3." Unicode::snprintfFloat(buffer, 20, "%6f", 3.14159f); // buffer=" 3.142" Unicode::snprintfFloat(buffer, 20, "%+06.f", 3.14159f); // buffer="+00003" \endcode If more control over the output is needed, see snprintfFloats which can have more than a single "%f" in the string and also supports "*" in place of a number. @warning The format string is internally copied from at char* to a UnicodeChar*. This buffer has a limit of 63 characters, so if the format is longer than 63 characters, the caller must do this copying to prevent an assert from triggering: \code{.cpp} touchgfx::Unicode::UnicodeChar tmpfmt[200]; touchgfx::Unicode::strncpy(tmpfmt, "Very, very, very, very, very, very, very, very, very long format %f", 200); touchgfx::Unicode::snprintfFloats(dst, dstSize, tmpfmt, values); \endcode @see snprintf, snprintfFloats. Read more...

snprintfFloats()

@fn static UnicodeChar* Unicode::snprintfFloats(UnicodeChar* dst, uint16_t dstSize, const UnicodeChar* format, const float* values); Variant of snprintf for floats only. Variant of snprintf for floats only. The format supports several \%f with flags/modifiers. The following is supported: %[flags][width][.precision]f Where flags can be:
'-': left justify the field (see width). '+': force sign. ' ': insert space if value is positive '\#': insert decimal point even if there are not decimals '0': left pad with zeros instead of spaces (see width)
Where width is the desired width of the output. If the value is larger, more characters may be generated, but not more than the parameter dstSize. If width is '*' the actual width is read from the list of values passed to this function. Where precision is the number of number of digits after the decimal point, default is 3. Use "%.f" to not generate any numbers after the decimal point. If precision is '*' the actual precision is read from the list of values passed to this function. \code{.cpp} float param1[3] = { 6.0f, 4.0f, 3.14159f }; Unicode::snprintfFloats(buffer, 20, "%*.*f", param1); // buffer="3.1416" float param2[2] = { 3.14159f, -123.4f }; Unicode::snprintfFloats(buffer, 20, "%f %f", param2); // buffer="3.142 -123.400" \endcode @see snprintf, snprintfFloat. Read more...

strlen()

@fn static uint16_t Unicode::strlen(const UnicodeChar* str); Gets the length of a 0-terminated unicode string. Gets the length of a 0-terminated unicode string. Read more...

strlen()

@fn static uint16_t Unicode::strlen(const UnicodeChar* str); Gets the length of a 0-terminated unicode string. Gets the length of a 0-terminated unicode string. Read more...

strncpy()

@fn static uint16_t Unicode::strncpy(UnicodeChar* RESTRICT dst, const UnicodeChar* RESTRICT src, uint16_t maxchars); Copy a string to a destination buffer, UnicodeChar to UnicodeChar version. Copy a string to a destination buffer, UnicodeChar to UnicodeChar version. Stops if it encounters a zero-termination, in which case the zero-termination is included in the destination string. Otherwise copies maxchars. @warning If there is no null-termination among the first n UnicodeChars of src, the string placed in destination will NOT be zero-terminated!. Read more...

strncpy()

@fn static uint16_t Unicode::strncpy(UnicodeChar* RESTRICT dst, const UnicodeChar* RESTRICT src, uint16_t maxchars); Copy a string to a destination buffer, UnicodeChar to UnicodeChar version. Copy a string to a destination buffer, UnicodeChar to UnicodeChar version. Stops if it encounters a zero-termination, in which case the zero-termination is included in the destination string. Otherwise copies maxchars. @warning If there is no null-termination among the first n UnicodeChars of src, the string placed in destination will NOT be zero-terminated!. Read more...

itoa()

@fn static void Unicode::itoa(int32_t value, UnicodeChar* buffer, uint16_t bufferSize, int radix); Integer to ASCII conversion. Integer to ASCII conversion. Read more...

utoa()

@fn static void Unicode::utoa(uint32_t value, UnicodeChar* buffer, uint16_t bufferSize, int radix); Integer to ASCII conversion. Integer to ASCII conversion. Read more...

atoi()

@fn static int Unicode::atoi(const UnicodeChar* s); String to integer conversion. String to integer conversion. Starts conversion at the start of the string. Running digits from here are converted. Read more...

snprintf()

@fn static UnicodeChar* Unicode::snprintf(UnicodeChar* dst, uint16_t dstSize, const UnicodeChar* format, ...); Formats a string and adds null termination. Formats a string and adds null termination. The string is formatted like when printf is used. Support formats: \%c (element type: char), \%s (element type: zero-terminated UnicodeChar list), \%u, \%i, \%d, \%o, \%x (all these are integers formatted in radix 10, 10, 10, 8, 16 respectively). The number formats (\%u, \%i, \%d, \%o and \%x) all support \%[0][length]X to specify the size of the generated field (length) and whether the number should be prefixed with zeros (or blanks). @see snprintfFloat, snprintfFloats. Read more...

vsnprintf()

@fn static UnicodeChar* Unicode::vsnprintf(UnicodeChar* dst, uint16_t dstSize, const char* format, va_list pArg); Variant of snprintf. Variant of snprintf. See snprintf for details. @see snprintf. Read more...

snprintf()

@fn static UnicodeChar* Unicode::snprintf(UnicodeChar* dst, uint16_t dstSize, const UnicodeChar* format, ...); Formats a string and adds null termination. Formats a string and adds null termination. The string is formatted like when printf is used. Support formats: \%c (element type: char), \%s (element type: zero-terminated UnicodeChar list), \%u, \%i, \%d, \%o, \%x (all these are integers formatted in radix 10, 10, 10, 8, 16 respectively). The number formats (\%u, \%i, \%d, \%o and \%x) all support \%[0][length]X to specify the size of the generated field (length) and whether the number should be prefixed with zeros (or blanks). @see snprintfFloat, snprintfFloats. Read more...

Examples

touchgfx::Unicode is referenced by 4 libraries and example projects.

References

LocationReferrerText
Unicode.hpp:29
class Unicode
ButtonWithLabel.hpp:158touchgfx::ButtonWithLabel::updateTextPosition()
const Unicode::UnicodeChar* s = typedText.getText();
ConstFont.hpp:60
ConstFont(const GlyphNode* list, uint16_t size, uint16_t height, uint8_t pixBelowBase, uint8_t bitsPerPixel, uint8_t maxLeft, uint8_t maxRight, const Unicode::UnicodeChar fallbackChar, const Unicode::UnicodeChar ellipsisChar);
ConstFont.hpp:81
virtual const GlyphNode* getGlyph(Unicode::UnicodeChar unicode, const uint8_t*& pixelData, uint8_t& bitsPerPixel) const;
ConstFont.hpp:108
virtual int8_t getKerning(Unicode::UnicodeChar prevChar, const GlyphNode* glyph) const = 0;
ConstFont.hpp:123
const GlyphNode* find(Unicode::UnicodeChar unicode) const;
Font.hpp:53
Unicode::UnicodeChar unicode; ///< The unicode of this glyph.
Font.hpp:133
Unicode::UnicodeChar unicodePrevChar; ///< The unicode for the first character in the kerning pair
Font.hpp:174
virtual const GlyphNode* getGlyph(Unicode::UnicodeChar unicode, const uint8_t*& pixelData, uint8_t& bitsPerPixel) const = 0;
Font.hpp:187touchgfx::Font::getGlyph() const
virtual const GlyphNode* getGlyph(Unicode::UnicodeChar unicode) const
Font.hpp:206touchgfx::Font::getFallbackChar() const
virtual Unicode::UnicodeChar getFallbackChar() const
Font.hpp:221touchgfx::Font::getEllipsisChar() const
virtual Unicode::UnicodeChar getEllipsisChar() const
Font.hpp:246
virtual uint16_t getStringWidth(const Unicode::UnicodeChar* text, ...) const;
Font.hpp:273
virtual uint16_t getStringWidth(TextDirection textDirection, const Unicode::UnicodeChar* text, ...) const;
Font.hpp:286
virtual uint16_t getCharWidth(const Unicode::UnicodeChar c) const;
Font.hpp:300
virtual uint8_t getSpacingAbove(const Unicode::UnicodeChar* text, ...) const;
Font.hpp:315
virtual uint16_t getMaxTextHeight(const Unicode::UnicodeChar* text, ...) const;
Font.hpp:409touchgfx::Font::getKerning() const
virtual int8_t getKerning(Unicode::UnicodeChar prevChar, const GlyphNode* glyph) const
Font.hpp:426
virtual uint16_t getNumberOfLines(const Unicode::UnicodeChar* text, ...) const;
Font.hpp:448
uint16_t getStringWidthLTR(TextDirection textDirection, const Unicode::UnicodeChar* text, va_list pArg) const;
Font.hpp:469
uint16_t getStringWidthRTL(TextDirection textDirection, const Unicode::UnicodeChar* text, va_list pArg) const;
Font.hpp:476
typedef uint16_t(Font::*StringWidthFunctionPointer)(TextDirection textDirection, const Unicode::UnicodeChar* text, va_list pArg) const;
Font.hpp:496touchgfx::Font::Font()
Font.hpp:503
Unicode::UnicodeChar falllbackCharacter; ///< The fallback character to use when no glyph exists for the wanted character
Font.hpp:504
Unicode::UnicodeChar ellipsisCharacter; ///< The ellipsis character used for truncating long texts.
HAL.hpp:338
virtual void registerTextCache(Unicode::UnicodeChar* str, uint16_t length);
HAL.hpp:354
virtual const Unicode::UnicodeChar* cacheTextString(const Unicode::UnicodeChar* str);
InternalFlashFont.hpp:61
InternalFlashFont(const GlyphNode* list, uint16_t size, uint16_t height, uint8_t pixBelowBase, uint8_t bitsPerPixel, uint8_t maxLeft, uint8_t maxRight, const uint8_t* glyphDataInternalFlash, const KerningNode* kerningList, const Unicode::UnicodeChar fallbackChar, const Unicode::UnicodeChar ellipsisChar);
InternalFlashFont.hpp:88
virtual int8_t getKerning(Unicode::UnicodeChar prevChar, const GlyphNode* glyph) const;
LCD.hpp:331
const Unicode::UnicodeChar* format,
LCD.hpp:508
const Unicode::UnicodeChar* format,
LCD.hpp:537
const Unicode::UnicodeChar* format,
LCD.hpp:580
typedef void (LCD::*DrawStringFunctionPointer)(const Rect& widgetArea, const Rect& invalidatedArea, const StringVisuals& stringVisuals, const Unicode::UnicodeChar* format, va_list _pArg);
LCD.hpp:599
LCD.hpp:609touchgfx::LCD::WideTextInternalStruct::WideTextInternalStruct()
Unicode::UnicodeChar ellipsisChar = font->getEllipsisChar();
LCD.hpp:622touchgfx::LCD::WideTextInternalStruct::getCurrChar() const
Unicode::UnicodeChar getCurrChar() const
LCD.hpp:639
TextArea.hpp:431
int16_t getTextHeightInternal(const Unicode::UnicodeChar* format, ...) const;
TextAreaWithWildcard.hpp:62
int16_t calculateTextHeight(const Unicode::UnicodeChar* format, ...) const;
TextAreaWithWildcard.hpp:138touchgfx::TextAreaWithOneWildcard::setWildcard()
void setWildcard(const Unicode::UnicodeChar* value)
TextAreaWithWildcard.hpp:152touchgfx::TextAreaWithOneWildcard::getWildcard() const
const Unicode::UnicodeChar* getWildcard() const
TextAreaWithWildcard.hpp:187
const Unicode::UnicodeChar* wildcard; ///< Pointer to the wildcard string. Must be zero-terminated.
TextAreaWithWildcard.hpp:263touchgfx::TextAreaWithTwoWildcards::setWildcard1()
void setWildcard1(const Unicode::UnicodeChar* value)
TextAreaWithWildcard.hpp:277touchgfx::TextAreaWithTwoWildcards::getWildcard1() const
const Unicode::UnicodeChar* getWildcard1() const
TextAreaWithWildcard.hpp:291touchgfx::TextAreaWithTwoWildcards::setWildcard2()
void setWildcard2(const Unicode::UnicodeChar* value)
TextAreaWithWildcard.hpp:305touchgfx::TextAreaWithTwoWildcards::getWildcard2() const
const Unicode::UnicodeChar* getWildcard2() const
TextAreaWithWildcard.hpp:340
const Unicode::UnicodeChar* wc1; ///< Pointer to the first wildcard string. Must be zero-terminated.
TextAreaWithWildcard.hpp:341
const Unicode::UnicodeChar* wc2; ///< Pointer to the second wildcard string. Must be zero-terminated.
TextProvider.hpp:60
void initialize(const Unicode::UnicodeChar* format, va_list pArg);
TextProvider.hpp:73
TextProvider.hpp:94
TextProvider.hpp:97
TextProvider.hpp:98
TextProvider.hpp:99
const Unicode::UnicodeChar* format;
TextProvider.hpp:101
const Unicode::UnicodeChar* substringPointer;
TextProvider.hpp:103
TextProvider.hpp:106
typedef Unicode::UnicodeChar(TextProvider::*UnicodeConverterFunctionPointer)(const Unicode::UnicodeChar currChar, const Unicode::UnicodeChar nextChar[2], const TextDirection direction);
TextProvider.hpp:112
Unicode::UnicodeChar unicodeConverter(const Unicode::UnicodeChar currChar, const Unicode::UnicodeChar nextChar[2], const TextDirection direction);
TextProvider.hpp:115
static Unicode::UnicodeChar contextualFormsTwoLong[][5];
TextProvider.hpp:116
TextProvider.hpp:117
TextProvider.hpp:118
Texts.hpp:78touchgfx::Texts::getText() const
const Unicode::UnicodeChar* getText(TypedTextId id) const
Texts.hpp:84
static const Unicode::UnicodeChar* const* currentLanguagePtr;
TypedText.hpp:120touchgfx::TypedText::getText() const
const Unicode::UnicodeChar* getText() const

Type Use

Variables of touchgfx::Unicode type
touchgfx::Unicode