/* * Copyright 2011, Haiku, Inc. All Rights Reserved. * Distributed under the terms of the OpenBeOS License. * * Authors: * Axel Dörfler * John Scipione * * Corresponds to: * /trunk/headers/os/locale/UnicodeChar.h rev 42274 * /trunk/src/kits/locale/UnicodeChar.cpp rev 42274 */ /*! \class BUnicodeChar \ingroup locale \brief Management of all information about characters. This class provide a set of tools for managing the whole set of characters defined by unicode. This include information about special sets of characters such as if the character is whitespace, or alphanumeric. It also provides the uppercase equivalent of a character and determines whether a character can be ornamented with accents. This class consists entirely of static methods, so you do not have to instantiate it. You can call one of the methods passing in the character that you want to be examined. Note all the function work with chars encoded in utf-32. This is not the most usual way to handle characters, but it is the fastest. To convert an utf-8 string to an utf-32 character use the FromUTF8() method. */ /*! \fn static bool BUnicodeChar::IsAlpha(uint32 c) \brief Determine if \a c is alphabetic. \returns \c true if the specified unicode character is an alphabetic character. */ /*! \fn static bool BUnicodeChar::IsAlNum(uint32 c) \brief Determine if \a c is alphanumeric. \returns \c true if the specified unicode character is a alphabetic or numeric character. */ /*! \fn static bool BUnicodeChar::IsDigit(uint32 c) \brief Determine if \a c is numeric. \returns \c true if the specified unicode character is a number character. */ /*! \fn static bool BUnicodeChar::IsHexDigit(uint32 c) \brief Determine if \a c is a hexadecimal digit. \returns \c true if the specified unicode character is a hexadecimal number character. */ /*! \fn static bool BUnicodeChar::IsUpper(uint32 c) \brief Determine if \a c is uppercase. \returns \c true if the specified unicode character is an uppercase character. */ /*! \fn static bool BUnicodeChar::IsLower(uint32 c) \brief Determine if \a c is lowercase. \returns \c true if the specified unicode character is a lowercase character. */ /*! \fn static bool BUnicodeChar::IsSpace(uint32 c) \brief Determine if \a c is a space. Unlike IsWhitespace() this function will return \c true for non-breakable spaces. This method is useful for determining if the character will render as an empty space which can be stretched on-screen. \returns \c true if the specified unicode character is some kind of a space character. \sa IsWhitespace() */ /*! \fn static bool BUnicodeChar::IsWhitespace(uint32 c) \brief Determine if \a c is whitespace. This method is essentially the same as IsSpace(), but excludes all non-breakable spaces. \returns \c true if the specified unicode character is a whitespace character. \sa IsSpace() */ /*! \fn static bool BUnicodeChar::IsControl(uint32 c) \brief Determine if \a c is a control character. Example control characters are the non-printable ASCII characters from 0x0 to 0x1F. \returns \c true if the specified unicode character is a control character. \sa IsPrintable() */ /*! \fn static bool BUnicodeChar::IsPunctuation(uint32 c) \brief Determine if \a c is punctuation character. \returns \c true if the specified unicode character is a punctuation character. */ /*! \fn static bool BUnicodeChar::IsPrintable(uint32 c) \brief Determine if \a c is printable. Printable characters are not control characters. \returns \c true if the specified unicode character is a printable character. \sa IsControl() */ /*! \fn static bool BUnicodeChar::IsTitle(uint32 c) \brief Determine if \a c is title case. Title case characters are a smaller version of normal uppercase letters. \returns \c true if the specified unicode character is a title case character. */ /*! \fn static bool BUnicodeChar::IsDefined(uint32 c) \brief Determine if \a c is defined. In unicode some codes are not valid or not attributed yet. For these codes this method will return \c false. \returns \c true if the specified unicode character is defined. */ /*! \fn static bool BUnicodeChar::IsBase(uint32 c) \brief Determine if \a c can be used with a diacritic. \note IsBase() does not determine if a unicode character is distinct. \returns \c true if the specified unicode character is a base form character that can be used with a diacritic. */ /*! \fn static int8 BUnicodeChar::Type(uint32 c) \brief Gets the type of a character. \returns A member of the \c unicode_char_category enum. */ /*! \fn uint32 BUnicodeChar::ToLower(uint32 c) \brief Transforms \a c to lowercase. \returns The lowercase version of the specified unicode character. */ /*! \fn uint32 BUnicodeChar::ToUpper(uint32 c) \brief Transforms \a c to uppercase. \returns The uppercase version of the specified unicode character. */ /*! \fn uint32 BUnicodeChar::ToTitle(uint32 c) \brief Transforms \a c to title case. \returns The title case version of the specified unicode character. */ /*! \fn int32 BUnicodeChar::DigitValue(uint32 c) \brief Gets the numeric value \a c. \returns The numeric version of the specified unicode character. */ /*! \fn void BUnicodeChar::ToUTF8(uint32 c, char **out) \brief Transform a character to utf-8 encoding. \returns The utf-8 encoding of the specified unicode character. */ /*! \fn uint32 BUnicodeChar::FromUTF8(const char **in) \brief Transform a utf-8 string to an utf-32 character. If the string contains multiple characters, only the fist one is used. This function updates the in pointer so that it points on the next character for the following call. \returns The utf-32 encoded version of \a in. */ /*! \fn size_t BUnicodeChar::UTF8StringLength(const char *str) \brief Counts the characters in the given \c NUL terminated string. \returns the number of utf-8 characters in the \c NUL terminated string. \sa BString::CountChars() */ /*! \fn size_t BUnicodeChar::UTF8StringLength(const char *str, size_t maxLength) \brief Counts the characters in the given string up to \a maxLength characters. The string does not need to be \c NUL terminated if you specify a \a maxLength that is shorter than the maximum length of the string. \returns the number of utf-8 characters in the \c NUL terminated string up to \a maxLength characters. */