summaryrefslogtreecommitdiff
path: root/source/modules/asura-core/Font
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2019-08-16 08:54:08 +0800
committerchai <chaifix@163.com>2019-08-16 08:54:08 +0800
commita077eb38b01292611f4f6031b75e3e2c1c20f06e (patch)
tree8f760483d7b0290952bbdb5bcd8f3943102aeb3a /source/modules/asura-core/Font
parent6a065c913e9308cc72e1ad0723b6167048f439b6 (diff)
Diffstat (limited to 'source/modules/asura-core/Font')
-rw-r--r--source/modules/asura-core/Font/TTF.cpp0
-rw-r--r--source/modules/asura-core/Font/TTF.h17
-rw-r--r--source/modules/asura-core/Font/Utf.hpp720
-rw-r--r--source/modules/asura-core/Font/Utf.inc752
4 files changed, 0 insertions, 1489 deletions
diff --git a/source/modules/asura-core/Font/TTF.cpp b/source/modules/asura-core/Font/TTF.cpp
deleted file mode 100644
index e69de29..0000000
--- a/source/modules/asura-core/Font/TTF.cpp
+++ /dev/null
diff --git a/source/modules/asura-core/Font/TTF.h b/source/modules/asura-core/Font/TTF.h
deleted file mode 100644
index b83cf76..0000000
--- a/source/modules/asura-core/Font/TTF.h
+++ /dev/null
@@ -1,17 +0,0 @@
-#ifndef _ASURA_TTF_H_
-#define _ASURA_TTF_H_
-
-namespace AsuraEngine
-{
- namespace Text
- {
-
- class TTF
- {
-
- };
-
- }
-}
-
-#endif \ No newline at end of file
diff --git a/source/modules/asura-core/Font/Utf.hpp b/source/modules/asura-core/Font/Utf.hpp
deleted file mode 100644
index 59f62ed..0000000
--- a/source/modules/asura-core/Font/Utf.hpp
+++ /dev/null
@@ -1,720 +0,0 @@
-#ifndef _ASURA_UTF_HPP_
-#define _ASURA_UTF_HPP_
-
-////////////////////////////////////////////////////////////
-// Headers
-////////////////////////////////////////////////////////////
-#include <algorithm>
-#include <locale>
-#include <string>
-#include <cstdlib>
-
-namespace AsuraEngine
-{
- namespace Text
- {
-
- template <unsigned int N>
- class Utf;
-
- ////////////////////////////////////////////////////////////
- /// \brief Specialization of the Utf template for UTF-8
- ///
- ////////////////////////////////////////////////////////////
- template <>
- class Utf<8>
- {
- public:
-
- ////////////////////////////////////////////////////////////
- /// \brief Decode a single UTF-8 character
- ///
- /// Decoding a character means finding its unique 32-bits
- /// code (called the codepoint) in the Unicode standard.
- ///
- /// \param begin Iterator pointing to the beginning of the input sequence
- /// \param end Iterator pointing to the end of the input sequence
- /// \param output Codepoint of the decoded UTF-8 character
- /// \param replacement Replacement character to use in case the UTF-8 sequence is invalid
- ///
- /// \return Iterator pointing to one past the last read element of the input sequence
- ///
- ////////////////////////////////////////////////////////////
- template <typename In>
- static In Decode(In begin, In end, Uint32& output, Uint32 replacement = 0);
-
- ////////////////////////////////////////////////////////////
- /// \brief Encode a single UTF-8 character
- ///
- /// Encoding a character means converting a unique 32-bits
- /// code (called the codepoint) in the target encoding, UTF-8.
- ///
- /// \param input Codepoint to encode as UTF-8
- /// \param output Iterator pointing to the beginning of the output sequence
- /// \param replacement Replacement for characters not convertible to UTF-8 (use 0 to skip them)
- ///
- /// \return Iterator to the end of the output sequence which has been written
- ///
- ////////////////////////////////////////////////////////////
- template <typename Out>
- static Out Encode(Uint32 input, Out output, Uint8 replacement = 0);
-
- ////////////////////////////////////////////////////////////
- /// \brief Advance to the next UTF-8 character
- ///
- /// This function is necessary for multi-elements encodings, as
- /// a single character may use more than 1 storage element.
- ///
- /// \param begin Iterator pointing to the beginning of the input sequence
- /// \param end Iterator pointing to the end of the input sequence
- ///
- /// \return Iterator pointing to one past the last read element of the input sequence
- ///
- ////////////////////////////////////////////////////////////
- template <typename In>
- static In Next(In begin, In end);
-
- ////////////////////////////////////////////////////////////
- /// \brief Count the number of characters of a UTF-8 sequence
- ///
- /// This function is necessary for multi-elements encodings, as
- /// a single character may use more than 1 storage element, thus the
- /// total size can be different from (begin - end).
- ///
- /// \param begin Iterator pointing to the beginning of the input sequence
- /// \param end Iterator pointing to the end of the input sequence
- ///
- /// \return Iterator pointing to one past the last read element of the input sequence
- ///
- ////////////////////////////////////////////////////////////
- template <typename In>
- static std::size_t Count(In begin, In end);
-
- ////////////////////////////////////////////////////////////
- /// \brief Convert an ANSI characters range to UTF-8
- ///
- /// The current global locale will be used by default, unless you
- /// pass a custom one in the \a locale parameter.
- ///
- /// \param begin Iterator pointing to the beginning of the input sequence
- /// \param end Iterator pointing to the end of the input sequence
- /// \param output Iterator pointing to the beginning of the output sequence
- /// \param locale Locale to use for conversion
- ///
- /// \return Iterator to the end of the output sequence which has been written
- ///
- ////////////////////////////////////////////////////////////
- template <typename In, typename Out>
- static Out FromAnsi(In begin, In end, Out output, const std::locale& locale = std::locale());
-
- ////////////////////////////////////////////////////////////
- /// \brief Convert a wide characters range to UTF-8
- ///
- /// \param begin Iterator pointing to the beginning of the input sequence
- /// \param end Iterator pointing to the end of the input sequence
- /// \param output Iterator pointing to the beginning of the output sequence
- ///
- /// \return Iterator to the end of the output sequence which has been written
- ///
- ////////////////////////////////////////////////////////////
- template <typename In, typename Out>
- static Out FromWide(In begin, In end, Out output);
-
- ////////////////////////////////////////////////////////////
- /// \brief Convert a latin-1 (ISO-5589-1) characters range to UTF-8
- ///
- /// \param begin Iterator pointing to the beginning of the input sequence
- /// \param end Iterator pointing to the end of the input sequence
- /// \param output Iterator pointing to the beginning of the output sequence
- ///
- /// \return Iterator to the end of the output sequence which has been written
- ///
- ////////////////////////////////////////////////////////////
- template <typename In, typename Out>
- static Out FromLatin1(In begin, In end, Out output);
-
- ////////////////////////////////////////////////////////////
- /// \brief Convert an UTF-8 characters range to ANSI characters
- ///
- /// The current global locale will be used by default, unless you
- /// pass a custom one in the \a locale parameter.
- ///
- /// \param begin Iterator pointing to the beginning of the input sequence
- /// \param end Iterator pointing to the end of the input sequence
- /// \param output Iterator pointing to the beginning of the output sequence
- /// \param replacement Replacement for characters not convertible to ANSI (use 0 to skip them)
- /// \param locale Locale to use for conversion
- ///
- /// \return Iterator to the end of the output sequence which has been written
- ///
- ////////////////////////////////////////////////////////////
- template <typename In, typename Out>
- static Out ToAnsi(In begin, In end, Out output, char replacement = 0, const std::locale& locale = std::locale());
-
- ////////////////////////////////////////////////////////////
- /// \brief Convert an UTF-8 characters range to wide characters
- ///
- /// \param begin Iterator pointing to the beginning of the input sequence
- /// \param end Iterator pointing to the end of the input sequence
- /// \param output Iterator pointing to the beginning of the output sequence
- /// \param replacement Replacement for characters not convertible to wide (use 0 to skip them)
- ///
- /// \return Iterator to the end of the output sequence which has been written
- ///
- ////////////////////////////////////////////////////////////
- template <typename In, typename Out>
- static Out ToWide(In begin, In end, Out output, wchar_t replacement = 0);
-
- ////////////////////////////////////////////////////////////
- /// \brief Convert an UTF-8 characters range to latin-1 (ISO-5589-1) characters
- ///
- /// \param begin Iterator pointing to the beginning of the input sequence
- /// \param end Iterator pointing to the end of the input sequence
- /// \param output Iterator pointing to the beginning of the output sequence
- /// \param replacement Replacement for characters not convertible to wide (use 0 to skip them)
- ///
- /// \return Iterator to the end of the output sequence which has been written
- ///
- ////////////////////////////////////////////////////////////
- template <typename In, typename Out>
- static Out ToLatin1(In begin, In end, Out output, char replacement = 0);
-
- ////////////////////////////////////////////////////////////
- /// \brief Convert a UTF-8 characters range to UTF-8
- ///
- /// This functions does nothing more than a direct copy;
- /// it is defined only to provide the same interface as other
- /// specializations of the sf::Utf<> template, and allow
- /// generic code to be written on top of it.
- ///
- /// \param begin Iterator pointing to the beginning of the input sequence
- /// \param end Iterator pointing to the end of the input sequence
- /// \param output Iterator pointing to the beginning of the output sequence
- ///
- /// \return Iterator to the end of the output sequence which has been written
- ///
- ////////////////////////////////////////////////////////////
- template <typename In, typename Out>
- static Out ToUtf8(In begin, In end, Out output);
-
- ////////////////////////////////////////////////////////////
- /// \brief Convert a UTF-8 characters range to UTF-16
- ///
- /// \param begin Iterator pointing to the beginning of the input sequence
- /// \param end Iterator pointing to the end of the input sequence
- /// \param output Iterator pointing to the beginning of the output sequence
- ///
- /// \return Iterator to the end of the output sequence which has been written
- ///
- ////////////////////////////////////////////////////////////
- template <typename In, typename Out>
- static Out ToUtf16(In begin, In end, Out output);
-
- ////////////////////////////////////////////////////////////
- /// \brief Convert a UTF-8 characters range to UTF-32
- ///
- /// \param begin Iterator pointing to the beginning of the input sequence
- /// \param end Iterator pointing to the end of the input sequence
- /// \param output Iterator pointing to the beginning of the output sequence
- ///
- /// \return Iterator to the end of the output sequence which has been written
- ///
- ////////////////////////////////////////////////////////////
- template <typename In, typename Out>
- static Out ToUtf32(In begin, In end, Out output);
- };
-
- ////////////////////////////////////////////////////////////
- /// \brief Specialization of the Utf template for UTF-16
- ///
- ////////////////////////////////////////////////////////////
- template <>
- class Utf<16>
- {
- public:
-
- ////////////////////////////////////////////////////////////
- /// \brief Decode a single UTF-16 character
- ///
- /// Decoding a character means finding its unique 32-bits
- /// code (called the codepoint) in the Unicode standard.
- ///
- /// \param begin Iterator pointing to the beginning of the input sequence
- /// \param end Iterator pointing to the end of the input sequence
- /// \param output Codepoint of the decoded UTF-16 character
- /// \param replacement Replacement character to use in case the UTF-8 sequence is invalid
- ///
- /// \return Iterator pointing to one past the last read element of the input sequence
- ///
- ////////////////////////////////////////////////////////////
- template <typename In>
- static In Decode(In begin, In end, Uint32& output, Uint32 replacement = 0);
-
- ////////////////////////////////////////////////////////////
- /// \brief Encode a single UTF-16 character
- ///
- /// Encoding a character means converting a unique 32-bits
- /// code (called the codepoint) in the target encoding, UTF-16.
- ///
- /// \param input Codepoint to encode as UTF-16
- /// \param output Iterator pointing to the beginning of the output sequence
- /// \param replacement Replacement for characters not convertible to UTF-16 (use 0 to skip them)
- ///
- /// \return Iterator to the end of the output sequence which has been written
- ///
- ////////////////////////////////////////////////////////////
- template <typename Out>
- static Out Encode(Uint32 input, Out output, Uint16 replacement = 0);
-
- ////////////////////////////////////////////////////////////
- /// \brief Advance to the next UTF-16 character
- ///
- /// This function is necessary for multi-elements encodings, as
- /// a single character may use more than 1 storage element.
- ///
- /// \param begin Iterator pointing to the beginning of the input sequence
- /// \param end Iterator pointing to the end of the input sequence
- ///
- /// \return Iterator pointing to one past the last read element of the input sequence
- ///
- ////////////////////////////////////////////////////////////
- template <typename In>
- static In Next(In begin, In end);
-
- ////////////////////////////////////////////////////////////
- /// \brief Count the number of characters of a UTF-16 sequence
- ///
- /// This function is necessary for multi-elements encodings, as
- /// a single character may use more than 1 storage element, thus the
- /// total size can be different from (begin - end).
- ///
- /// \param begin Iterator pointing to the beginning of the input sequence
- /// \param end Iterator pointing to the end of the input sequence
- ///
- /// \return Iterator pointing to one past the last read element of the input sequence
- ///
- ////////////////////////////////////////////////////////////
- template <typename In>
- static std::size_t Count(In begin, In end);
-
- ////////////////////////////////////////////////////////////
- /// \brief Convert an ANSI characters range to UTF-16
- ///
- /// The current global locale will be used by default, unless you
- /// pass a custom one in the \a locale parameter.
- ///
- /// \param begin Iterator pointing to the beginning of the input sequence
- /// \param end Iterator pointing to the end of the input sequence
- /// \param output Iterator pointing to the beginning of the output sequence
- /// \param locale Locale to use for conversion
- ///
- /// \return Iterator to the end of the output sequence which has been written
- ///
- ////////////////////////////////////////////////////////////
- template <typename In, typename Out>
- static Out FromAnsi(In begin, In end, Out output, const std::locale& locale = std::locale());
-
- ////////////////////////////////////////////////////////////
- /// \brief Convert a wide characters range to UTF-16
- ///
- /// \param begin Iterator pointing to the beginning of the input sequence
- /// \param end Iterator pointing to the end of the input sequence
- /// \param output Iterator pointing to the beginning of the output sequence
- ///
- /// \return Iterator to the end of the output sequence which has been written
- ///
- ////////////////////////////////////////////////////////////
- template <typename In, typename Out>
- static Out FromWide(In begin, In end, Out output);
-
- ////////////////////////////////////////////////////////////
- /// \brief Convert a latin-1 (ISO-5589-1) characters range to UTF-16
- ///
- /// \param begin Iterator pointing to the beginning of the input sequence
- /// \param end Iterator pointing to the end of the input sequence
- /// \param output Iterator pointing to the beginning of the output sequence
- ///
- /// \return Iterator to the end of the output sequence which has been written
- ///
- ////////////////////////////////////////////////////////////
- template <typename In, typename Out>
- static Out FromLatin1(In begin, In end, Out output);
-
- ////////////////////////////////////////////////////////////
- /// \brief Convert an UTF-16 characters range to ANSI characters
- ///
- /// The current global locale will be used by default, unless you
- /// pass a custom one in the \a locale parameter.
- ///
- /// \param begin Iterator pointing to the beginning of the input sequence
- /// \param end Iterator pointing to the end of the input sequence
- /// \param output Iterator pointing to the beginning of the output sequence
- /// \param replacement Replacement for characters not convertible to ANSI (use 0 to skip them)
- /// \param locale Locale to use for conversion
- ///
- /// \return Iterator to the end of the output sequence which has been written
- ///
- ////////////////////////////////////////////////////////////
- template <typename In, typename Out>
- static Out ToAnsi(In begin, In end, Out output, char replacement = 0, const std::locale& locale = std::locale());
-
- ////////////////////////////////////////////////////////////
- /// \brief Convert an UTF-16 characters range to wide characters
- ///
- /// \param begin Iterator pointing to the beginning of the input sequence
- /// \param end Iterator pointing to the end of the input sequence
- /// \param output Iterator pointing to the beginning of the output sequence
- /// \param replacement Replacement for characters not convertible to wide (use 0 to skip them)
- ///
- /// \return Iterator to the end of the output sequence which has been written
- ///
- ////////////////////////////////////////////////////////////
- template <typename In, typename Out>
- static Out ToWide(In begin, In end, Out output, wchar_t replacement = 0);
-
- ////////////////////////////////////////////////////////////
- /// \brief Convert an UTF-16 characters range to latin-1 (ISO-5589-1) characters
- ///
- /// \param begin Iterator pointing to the beginning of the input sequence
- /// \param end Iterator pointing to the end of the input sequence
- /// \param output Iterator pointing to the beginning of the output sequence
- /// \param replacement Replacement for characters not convertible to wide (use 0 to skip them)
- ///
- /// \return Iterator to the end of the output sequence which has been written
- ///
- ////////////////////////////////////////////////////////////
- template <typename In, typename Out>
- static Out ToLatin1(In begin, In end, Out output, char replacement = 0);
-
- ////////////////////////////////////////////////////////////
- /// \brief Convert a UTF-16 characters range to UTF-8
- ///
- /// \param begin Iterator pointing to the beginning of the input sequence
- /// \param end Iterator pointing to the end of the input sequence
- /// \param output Iterator pointing to the beginning of the output sequence
- ///
- /// \return Iterator to the end of the output sequence which has been written
- ///
- ////////////////////////////////////////////////////////////
- template <typename In, typename Out>
- static Out ToUtf8(In begin, In end, Out output);
-
- ////////////////////////////////////////////////////////////
- /// \brief Convert a UTF-16 characters range to UTF-16
- ///
- /// This functions does nothing more than a direct copy;
- /// it is defined only to provide the same interface as other
- /// specializations of the sf::Utf<> template, and allow
- /// generic code to be written on top of it.
- ///
- /// \param begin Iterator pointing to the beginning of the input sequence
- /// \param end Iterator pointing to the end of the input sequence
- /// \param output Iterator pointing to the beginning of the output sequence
- ///
- /// \return Iterator to the end of the output sequence which has been written
- ///
- ////////////////////////////////////////////////////////////
- template <typename In, typename Out>
- static Out ToUtf16(In begin, In end, Out output);
-
- ////////////////////////////////////////////////////////////
- /// \brief Convert a UTF-16 characters range to UTF-32
- ///
- /// \param begin Iterator pointing to the beginning of the input sequence
- /// \param end Iterator pointing to the end of the input sequence
- /// \param output Iterator pointing to the beginning of the output sequence
- ///
- /// \return Iterator to the end of the output sequence which has been written
- ///
- ////////////////////////////////////////////////////////////
- template <typename In, typename Out>
- static Out ToUtf32(In begin, In end, Out output);
- };
-
- ////////////////////////////////////////////////////////////
- /// \brief Specialization of the Utf template for UTF-32
- ///
- ////////////////////////////////////////////////////////////
- template <>
- class Utf<32>
- {
- public:
-
- ////////////////////////////////////////////////////////////
- /// \brief Decode a single UTF-32 character
- ///
- /// Decoding a character means finding its unique 32-bits
- /// code (called the codepoint) in the Unicode standard.
- /// For UTF-32, the character value is the same as the codepoint.
- ///
- /// \param begin Iterator pointing to the beginning of the input sequence
- /// \param end Iterator pointing to the end of the input sequence
- /// \param output Codepoint of the decoded UTF-32 character
- /// \param replacement Replacement character to use in case the UTF-8 sequence is invalid
- ///
- /// \return Iterator pointing to one past the last read element of the input sequence
- ///
- ////////////////////////////////////////////////////////////
- template <typename In>
- static In Decode(In begin, In end, Uint32& output, Uint32 replacement = 0);
-
- ////////////////////////////////////////////////////////////
- /// \brief Encode a single UTF-32 character
- ///
- /// Encoding a character means converting a unique 32-bits
- /// code (called the codepoint) in the target encoding, UTF-32.
- /// For UTF-32, the codepoint is the same as the character value.
- ///
- /// \param input Codepoint to encode as UTF-32
- /// \param output Iterator pointing to the beginning of the output sequence
- /// \param replacement Replacement for characters not convertible to UTF-32 (use 0 to skip them)
- ///
- /// \return Iterator to the end of the output sequence which has been written
- ///
- ////////////////////////////////////////////////////////////
- template <typename Out>
- static Out Encode(Uint32 input, Out output, Uint32 replacement = 0);
-
- ////////////////////////////////////////////////////////////
- /// \brief Advance to the next UTF-32 character
- ///
- /// This function is trivial for UTF-32, which can store
- /// every character in a single storage element.
- ///
- /// \param begin Iterator pointing to the beginning of the input sequence
- /// \param end Iterator pointing to the end of the input sequence
- ///
- /// \return Iterator pointing to one past the last read element of the input sequence
- ///
- ////////////////////////////////////////////////////////////
- template <typename In>
- static In Next(In begin, In end);
-
- ////////////////////////////////////////////////////////////
- /// \brief Count the number of characters of a UTF-32 sequence
- ///
- /// This function is trivial for UTF-32, which can store
- /// every character in a single storage element.
- ///
- /// \param begin Iterator pointing to the beginning of the input sequence
- /// \param end Iterator pointing to the end of the input sequence
- ///
- /// \return Iterator pointing to one past the last read element of the input sequence
- ///
- ////////////////////////////////////////////////////////////
- template <typename In>
- static std::size_t Count(In begin, In end);
-
- ////////////////////////////////////////////////////////////
- /// \brief Convert an ANSI characters range to UTF-32
- ///
- /// The current global locale will be used by default, unless you
- /// pass a custom one in the \a locale parameter.
- ///
- /// \param begin Iterator pointing to the beginning of the input sequence
- /// \param end Iterator pointing to the end of the input sequence
- /// \param output Iterator pointing to the beginning of the output sequence
- /// \param locale Locale to use for conversion
- ///
- /// \return Iterator to the end of the output sequence which has been written
- ///
- ////////////////////////////////////////////////////////////
- template <typename In, typename Out>
- static Out FromAnsi(In begin, In end, Out output, const std::locale& locale = std::locale());
-
- ////////////////////////////////////////////////////////////
- /// \brief Convert a wide characters range to UTF-32
- ///
- /// \param begin Iterator pointing to the beginning of the input sequence
- /// \param end Iterator pointing to the end of the input sequence
- /// \param output Iterator pointing to the beginning of the output sequence
- ///
- /// \return Iterator to the end of the output sequence which has been written
- ///
- ////////////////////////////////////////////////////////////
- template <typename In, typename Out>
- static Out FromWide(In begin, In end, Out output);
-
- ////////////////////////////////////////////////////////////
- /// \brief Convert a latin-1 (ISO-5589-1) characters range to UTF-32
- ///
- /// \param begin Iterator pointing to the beginning of the input sequence
- /// \param end Iterator pointing to the end of the input sequence
- /// \param output Iterator pointing to the beginning of the output sequence
- ///
- /// \return Iterator to the end of the output sequence which has been written
- ///
- ////////////////////////////////////////////////////////////
- template <typename In, typename Out>
- static Out FromLatin1(In begin, In end, Out output);
-
- ////////////////////////////////////////////////////////////
- /// \brief Convert an UTF-32 characters range to ANSI characters
- ///
- /// The current global locale will be used by default, unless you
- /// pass a custom one in the \a locale parameter.
- ///
- /// \param begin Iterator pointing to the beginning of the input sequence
- /// \param end Iterator pointing to the end of the input sequence
- /// \param output Iterator pointing to the beginning of the output sequence
- /// \param replacement Replacement for characters not convertible to ANSI (use 0 to skip them)
- /// \param locale Locale to use for conversion
- ///
- /// \return Iterator to the end of the output sequence which has been written
- ///
- ////////////////////////////////////////////////////////////
- template <typename In, typename Out>
- static Out ToAnsi(In begin, In end, Out output, char replacement = 0, const std::locale& locale = std::locale());
-
- ////////////////////////////////////////////////////////////
- /// \brief Convert an UTF-32 characters range to wide characters
- ///
- /// \param begin Iterator pointing to the beginning of the input sequence
- /// \param end Iterator pointing to the end of the input sequence
- /// \param output Iterator pointing to the beginning of the output sequence
- /// \param replacement Replacement for characters not convertible to wide (use 0 to skip them)
- ///
- /// \return Iterator to the end of the output sequence which has been written
- ///
- ////////////////////////////////////////////////////////////
- template <typename In, typename Out>
- static Out ToWide(In begin, In end, Out output, wchar_t replacement = 0);
-
- ////////////////////////////////////////////////////////////
- /// \brief Convert an UTF-16 characters range to latin-1 (ISO-5589-1) characters
- ///
- /// \param begin Iterator pointing to the beginning of the input sequence
- /// \param end Iterator pointing to the end of the input sequence
- /// \param output Iterator pointing to the beginning of the output sequence
- /// \param replacement Replacement for characters not convertible to wide (use 0 to skip them)
- ///
- /// \return Iterator to the end of the output sequence which has been written
- ///
- ////////////////////////////////////////////////////////////
- template <typename In, typename Out>
- static Out ToLatin1(In begin, In end, Out output, char replacement = 0);
-
- ////////////////////////////////////////////////////////////
- /// \brief Convert a UTF-32 characters range to UTF-8
- ///
- /// \param begin Iterator pointing to the beginning of the input sequence
- /// \param end Iterator pointing to the end of the input sequence
- /// \param output Iterator pointing to the beginning of the output sequence
- ///
- /// \return Iterator to the end of the output sequence which has been written
- ///
- ////////////////////////////////////////////////////////////
- template <typename In, typename Out>
- static Out ToUtf8(In begin, In end, Out output);
-
- ////////////////////////////////////////////////////////////
- /// \brief Convert a UTF-32 characters range to UTF-16
- ///
- /// \param begin Iterator pointing to the beginning of the input sequence
- /// \param end Iterator pointing to the end of the input sequence
- /// \param output Iterator pointing to the beginning of the output sequence
- ///
- /// \return Iterator to the end of the output sequence which has been written
- ///
- ////////////////////////////////////////////////////////////
- template <typename In, typename Out>
- static Out ToUtf16(In begin, In end, Out output);
-
- ////////////////////////////////////////////////////////////
- /// \brief Convert a UTF-32 characters range to UTF-32
- ///
- /// This functions does nothing more than a direct copy;
- /// it is defined only to provide the same interface as other
- /// specializations of the sf::Utf<> template, and allow
- /// generic code to be written on top of it.
- ///
- /// \param begin Iterator pointing to the beginning of the input sequence
- /// \param end Iterator pointing to the end of the input sequence
- /// \param output Iterator pointing to the beginning of the output sequence
- ///
- /// \return Iterator to the end of the output sequence which has been written
- ///
- ////////////////////////////////////////////////////////////
- template <typename In, typename Out>
- static Out ToUtf32(In begin, In end, Out output);
-
- ////////////////////////////////////////////////////////////
- /// \brief Decode a single ANSI character to UTF-32
- ///
- /// This function does not exist in other specializations
- /// of sf::Utf<>, it is defined for convenience (it is used by
- /// several other conversion functions).
- ///
- /// \param input Input ANSI character
- /// \param locale Locale to use for conversion
- ///
- /// \return Converted character
- ///
- ////////////////////////////////////////////////////////////
- template <typename In>
- static Uint32 DecodeAnsi(In input, const std::locale& locale = std::locale());
-
- ////////////////////////////////////////////////////////////
- /// \brief Decode a single wide character to UTF-32
- ///
- /// This function does not exist in other specializations
- /// of sf::Utf<>, it is defined for convenience (it is used by
- /// several other conversion functions).
- ///
- /// \param input Input wide character
- ///
- /// \return Converted character
- ///
- ////////////////////////////////////////////////////////////
- template <typename In>
- static Uint32 DecodeWide(In input);
-
- ////////////////////////////////////////////////////////////
- /// \brief Encode a single UTF-32 character to ANSI
- ///
- /// This function does not exist in other specializations
- /// of sf::Utf<>, it is defined for convenience (it is used by
- /// several other conversion functions).
- ///
- /// \param codepoint Iterator pointing to the beginning of the input sequence
- /// \param output Iterator pointing to the beginning of the output sequence
- /// \param replacement Replacement if the input character is not convertible to ANSI (use 0 to skip it)
- /// \param locale Locale to use for conversion
- ///
- /// \return Iterator to the end of the output sequence which has been written
- ///
- ////////////////////////////////////////////////////////////
- template <typename Out>
- static Out EncodeAnsi(Uint32 codepoint, Out output, char replacement = 0, const std::locale& locale = std::locale());
-
- ////////////////////////////////////////////////////////////
- /// \brief Encode a single UTF-32 character to wide
- ///
- /// This function does not exist in other specializations
- /// of sf::Utf<>, it is defined for convenience (it is used by
- /// several other conversion functions).
- ///
- /// \param codepoint Iterator pointing to the beginning of the input sequence
- /// \param output Iterator pointing to the beginning of the output sequence
- /// \param replacement Replacement if the input character is not convertible to wide (use 0 to skip it)
- ///
- /// \return Iterator to the end of the output sequence which has been written
- ///
- ////////////////////////////////////////////////////////////
- template <typename Out>
- static Out EncodeWide(Uint32 codepoint, Out output, wchar_t replacement = 0);
- };
-
-#include "Utf.inc"
-
- // Make typedefs to get rid of the template syntax
- typedef Utf<8> Utf8;
- typedef Utf<16> Utf16;
- typedef Utf<32> Utf32;
-
- } // namespace sf
-
-}
-
-
-#endif // SFML_UTF_HPP
diff --git a/source/modules/asura-core/Font/Utf.inc b/source/modules/asura-core/Font/Utf.inc
deleted file mode 100644
index 69a523b..0000000
--- a/source/modules/asura-core/Font/Utf.inc
+++ /dev/null
@@ -1,752 +0,0 @@
-////////////////////////////////////////////////////////////
-//
-// SFML - Simple and Fast Multimedia Library
-// Copyright (C) 2007-2019 Laurent Gomila (laurent@sfml-dev.org)
-//
-// This software is provided 'as-is', without any express or implied warranty.
-// In no event will the authors be held liable for any damages arising from the use of this software.
-//
-// Permission is granted to anyone to use this software for any purpose,
-// including commercial applications, and to alter it and redistribute it freely,
-// subject to the following restrictions:
-//
-// 1. The origin of this software must not be misrepresented;
-// you must not claim that you wrote the original software.
-// If you use this software in a product, an acknowledgment
-// in the product documentation would be appreciated but is not required.
-//
-// 2. Altered source versions must be plainly marked as such,
-// and must not be misrepresented as being the original software.
-//
-// 3. This notice may not be removed or altered from any source distribution.
-//
-////////////////////////////////////////////////////////////
-
-
-////////////////////////////////////////////////////////////
-// References:
-//
-// https://www.unicode.org/
-// https://www.unicode.org/Public/PROGRAMS/CVTUTF/ConvertUTF.c
-// https://www.unicode.org/Public/PROGRAMS/CVTUTF/ConvertUTF.h
-// https://people.w3.org/rishida/scripts/uniview/conversion
-//
-////////////////////////////////////////////////////////////
-
-
-////////////////////////////////////////////////////////////
-template <typename In>
-In Utf<8>::Decode(In begin, In end, Uint32& output, Uint32 replacement)
-{
- // Some useful precomputed data
- static const int trailing[256] =
- {
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5
- };
- static const Uint32 offsets[6] =
- {
- 0x00000000, 0x00003080, 0x000E2080, 0x03C82080, 0xFA082080, 0x82082080
- };
-
- // decode the character
- int trailingBytes = trailing[static_cast<Uint8>(*begin)];
- if (begin + trailingBytes < end)
- {
- output = 0;
- switch (trailingBytes)
- {
- case 5: output += static_cast<Uint8>(*begin++); output <<= 6;
- case 4: output += static_cast<Uint8>(*begin++); output <<= 6;
- case 3: output += static_cast<Uint8>(*begin++); output <<= 6;
- case 2: output += static_cast<Uint8>(*begin++); output <<= 6;
- case 1: output += static_cast<Uint8>(*begin++); output <<= 6;
- case 0: output += static_cast<Uint8>(*begin++);
- }
- output -= offsets[trailingBytes];
- }
- else
- {
- // Incomplete character
- begin = end;
- output = replacement;
- }
-
- return begin;
-}
-
-
-////////////////////////////////////////////////////////////
-template <typename Out>
-Out Utf<8>::Encode(Uint32 input, Out output, Uint8 replacement)
-{
- // Some useful precomputed data
- static const Uint8 firstBytes[7] =
- {
- 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC
- };
-
- // encode the character
- if ((input > 0x0010FFFF) || ((input >= 0xD800) && (input <= 0xDBFF)))
- {
- // Invalid character
- if (replacement)
- *output++ = replacement;
- }
- else
- {
- // Valid character
-
- // Get the number of bytes to write
- std::size_t bytestoWrite = 1;
- if (input < 0x80) bytestoWrite = 1;
- else if (input < 0x800) bytestoWrite = 2;
- else if (input < 0x10000) bytestoWrite = 3;
- else if (input <= 0x0010FFFF) bytestoWrite = 4;
-
- // Extract the bytes to write
- Uint8 bytes[4];
- switch (bytestoWrite)
- {
- case 4: bytes[3] = static_cast<Uint8>((input | 0x80) & 0xBF); input >>= 6;
- case 3: bytes[2] = static_cast<Uint8>((input | 0x80) & 0xBF); input >>= 6;
- case 2: bytes[1] = static_cast<Uint8>((input | 0x80) & 0xBF); input >>= 6;
- case 1: bytes[0] = static_cast<Uint8> (input | firstBytes[bytestoWrite]);
- }
-
- // Add them to the output
- output = std::copy(bytes, bytes + bytestoWrite, output);
- }
-
- return output;
-}
-
-
-////////////////////////////////////////////////////////////
-template <typename In>
-In Utf<8>::Next(In begin, In end)
-{
- Uint32 codepoint;
- return Decode(begin, end, codepoint);
-}
-
-
-////////////////////////////////////////////////////////////
-template <typename In>
-std::size_t Utf<8>::Count(In begin, In end)
-{
- std::size_t length = 0;
- while (begin < end)
- {
- begin = Next(begin, end);
- ++length;
- }
-
- return length;
-}
-
-
-////////////////////////////////////////////////////////////
-template <typename In, typename Out>
-Out Utf<8>::FromAnsi(In begin, In end, Out output, const std::locale& locale)
-{
- while (begin < end)
- {
- Uint32 codepoint = Utf<32>::DecodeAnsi(*begin++, locale);
- output = Encode(codepoint, output);
- }
-
- return output;
-}
-
-
-////////////////////////////////////////////////////////////
-template <typename In, typename Out>
-Out Utf<8>::FromWide(In begin, In end, Out output)
-{
- while (begin < end)
- {
- Uint32 codepoint = Utf<32>::DecodeWide(*begin++);
- output = Encode(codepoint, output);
- }
-
- return output;
-}
-
-
-////////////////////////////////////////////////////////////
-template <typename In, typename Out>
-Out Utf<8>::FromLatin1(In begin, In end, Out output)
-{
- // Latin-1 is directly compatible with Unicode encodings,
- // and can thus be treated as (a sub-range of) UTF-32
- while (begin < end)
- output = Encode(*begin++, output);
-
- return output;
-}
-
-
-////////////////////////////////////////////////////////////
-template <typename In, typename Out>
-Out Utf<8>::ToAnsi(In begin, In end, Out output, char replacement, const std::locale& locale)
-{
- while (begin < end)
- {
- Uint32 codepoint;
- begin = Decode(begin, end, codepoint);
- output = Utf<32>::EncodeAnsi(codepoint, output, replacement, locale);
- }
-
- return output;
-}
-
-
-////////////////////////////////////////////////////////////
-template <typename In, typename Out>
-Out Utf<8>::ToWide(In begin, In end, Out output, wchar_t replacement)
-{
- while (begin < end)
- {
- Uint32 codepoint;
- begin = Decode(begin, end, codepoint);
- output = Utf<32>::EncodeWide(codepoint, output, replacement);
- }
-
- return output;
-}
-
-
-////////////////////////////////////////////////////////////
-template <typename In, typename Out>
-Out Utf<8>::ToLatin1(In begin, In end, Out output, char replacement)
-{
- // Latin-1 is directly compatible with Unicode encodings,
- // and can thus be treated as (a sub-range of) UTF-32
- while (begin < end)
- {
- Uint32 codepoint;
- begin = Decode(begin, end, codepoint);
- *output++ = codepoint < 256 ? static_cast<char>(codepoint) : replacement;
- }
-
- return output;
-}
-
-
-////////////////////////////////////////////////////////////
-template <typename In, typename Out>
-Out Utf<8>::ToUtf8(In begin, In end, Out output)
-{
- return std::copy(begin, end, output);
-}
-
-
-////////////////////////////////////////////////////////////
-template <typename In, typename Out>
-Out Utf<8>::ToUtf16(In begin, In end, Out output)
-{
- while (begin < end)
- {
- Uint32 codepoint;
- begin = Decode(begin, end, codepoint);
- output = Utf<16>::Encode(codepoint, output);
- }
-
- return output;
-}
-
-
-////////////////////////////////////////////////////////////
-template <typename In, typename Out>
-Out Utf<8>::ToUtf32(In begin, In end, Out output)
-{
- while (begin < end)
- {
- Uint32 codepoint;
- begin = Decode(begin, end, codepoint);
- *output++ = codepoint;
- }
-
- return output;
-}
-
-
-////////////////////////////////////////////////////////////
-template <typename In>
-In Utf<16>::Decode(In begin, In end, Uint32& output, Uint32 replacement)
-{
- Uint16 first = *begin++;
-
- // If it's a surrogate pair, first convert to a single UTF-32 character
- if ((first >= 0xD800) && (first <= 0xDBFF))
- {
- if (begin < end)
- {
- Uint32 second = *begin++;
- if ((second >= 0xDC00) && (second <= 0xDFFF))
- {
- // The second element is valid: convert the two elements to a UTF-32 character
- output = ((first - 0xD800) << 10) + (second - 0xDC00) + 0x0010000;
- }
- else
- {
- // Invalid character
- output = replacement;
- }
- }
- else
- {
- // Invalid character
- begin = end;
- output = replacement;
- }
- }
- else
- {
- // We can make a direct copy
- output = first;
- }
-
- return begin;
-}
-
-
-////////////////////////////////////////////////////////////
-template <typename Out>
-Out Utf<16>::Encode(Uint32 input, Out output, Uint16 replacement)
-{
- if (input <= 0xFFFF)
- {
- // The character can be copied directly, we just need to check if it's in the valid range
- if ((input >= 0xD800) && (input <= 0xDFFF))
- {
- // Invalid character (this range is reserved)
- if (replacement)
- *output++ = replacement;
- }
- else
- {
- // Valid character directly convertible to a single UTF-16 character
- *output++ = static_cast<Uint16>(input);
- }
- }
- else if (input > 0x0010FFFF)
- {
- // Invalid character (greater than the maximum Unicode value)
- if (replacement)
- *output++ = replacement;
- }
- else
- {
- // The input character will be converted to two UTF-16 elements
- input -= 0x0010000;
- *output++ = static_cast<Uint16>((input >> 10) + 0xD800);
- *output++ = static_cast<Uint16>((input & 0x3FFUL) + 0xDC00);
- }
-
- return output;
-}
-
-
-////////////////////////////////////////////////////////////
-template <typename In>
-In Utf<16>::Next(In begin, In end)
-{
- Uint32 codepoint;
- return Decode(begin, end, codepoint);
-}
-
-
-////////////////////////////////////////////////////////////
-template <typename In>
-std::size_t Utf<16>::Count(In begin, In end)
-{
- std::size_t length = 0;
- while (begin < end)
- {
- begin = Next(begin, end);
- ++length;
- }
-
- return length;
-}
-
-
-////////////////////////////////////////////////////////////
-template <typename In, typename Out>
-Out Utf<16>::FromAnsi(In begin, In end, Out output, const std::locale& locale)
-{
- while (begin < end)
- {
- Uint32 codepoint = Utf<32>::DecodeAnsi(*begin++, locale);
- output = Encode(codepoint, output);
- }
-
- return output;
-}
-
-
-////////////////////////////////////////////////////////////
-template <typename In, typename Out>
-Out Utf<16>::FromWide(In begin, In end, Out output)
-{
- while (begin < end)
- {
- Uint32 codepoint = Utf<32>::DecodeWide(*begin++);
- output = Encode(codepoint, output);
- }
-
- return output;
-}
-
-
-////////////////////////////////////////////////////////////
-template <typename In, typename Out>
-Out Utf<16>::FromLatin1(In begin, In end, Out output)
-{
- // Latin-1 is directly compatible with Unicode encodings,
- // and can thus be treated as (a sub-range of) UTF-32
- return std::copy(begin, end, output);
-}
-
-
-////////////////////////////////////////////////////////////
-template <typename In, typename Out>
-Out Utf<16>::ToAnsi(In begin, In end, Out output, char replacement, const std::locale& locale)
-{
- while (begin < end)
- {
- Uint32 codepoint;
- begin = Decode(begin, end, codepoint);
- output = Utf<32>::EncodeAnsi(codepoint, output, replacement, locale);
- }
-
- return output;
-}
-
-
-////////////////////////////////////////////////////////////
-template <typename In, typename Out>
-Out Utf<16>::ToWide(In begin, In end, Out output, wchar_t replacement)
-{
- while (begin < end)
- {
- Uint32 codepoint;
- begin = Decode(begin, end, codepoint);
- output = Utf<32>::EncodeWide(codepoint, output, replacement);
- }
-
- return output;
-}
-
-
-////////////////////////////////////////////////////////////
-template <typename In, typename Out>
-Out Utf<16>::ToLatin1(In begin, In end, Out output, char replacement)
-{
- // Latin-1 is directly compatible with Unicode encodings,
- // and can thus be treated as (a sub-range of) UTF-32
- while (begin < end)
- {
- *output++ = *begin < 256 ? static_cast<char>(*begin) : replacement;
- begin++;
- }
-
- return output;
-}
-
-
-////////////////////////////////////////////////////////////
-template <typename In, typename Out>
-Out Utf<16>::ToUtf8(In begin, In end, Out output)
-{
- while (begin < end)
- {
- Uint32 codepoint;
- begin = Decode(begin, end, codepoint);
- output = Utf<8>::Encode(codepoint, output);
- }
-
- return output;
-}
-
-
-////////////////////////////////////////////////////////////
-template <typename In, typename Out>
-Out Utf<16>::ToUtf16(In begin, In end, Out output)
-{
- return std::copy(begin, end, output);
-}
-
-
-////////////////////////////////////////////////////////////
-template <typename In, typename Out>
-Out Utf<16>::ToUtf32(In begin, In end, Out output)
-{
- while (begin < end)
- {
- Uint32 codepoint;
- begin = Decode(begin, end, codepoint);
- *output++ = codepoint;
- }
-
- return output;
-}
-
-
-////////////////////////////////////////////////////////////
-template <typename In>
-In Utf<32>::Decode(In begin, In /*end*/, Uint32& output, Uint32 /*replacement*/)
-{
- output = *begin++;
- return begin;
-}
-
-
-////////////////////////////////////////////////////////////
-template <typename Out>
-Out Utf<32>::Encode(Uint32 input, Out output, Uint32 /*replacement*/)
-{
- *output++ = input;
- return output;
-}
-
-
-////////////////////////////////////////////////////////////
-template <typename In>
-In Utf<32>::Next(In begin, In /*end*/)
-{
- return ++begin;
-}
-
-
-////////////////////////////////////////////////////////////
-template <typename In>
-std::size_t Utf<32>::Count(In begin, In end)
-{
- return begin - end;
-}
-
-
-////////////////////////////////////////////////////////////
-template <typename In, typename Out>
-Out Utf<32>::FromAnsi(In begin, In end, Out output, const std::locale& locale)
-{
- while (begin < end)
- *output++ = DecodeAnsi(*begin++, locale);
-
- return output;
-}
-
-
-////////////////////////////////////////////////////////////
-template <typename In, typename Out>
-Out Utf<32>::FromWide(In begin, In end, Out output)
-{
- while (begin < end)
- *output++ = DecodeWide(*begin++);
-
- return output;
-}
-
-
-////////////////////////////////////////////////////////////
-template <typename In, typename Out>
-Out Utf<32>::FromLatin1(In begin, In end, Out output)
-{
- // Latin-1 is directly compatible with Unicode encodings,
- // and can thus be treated as (a sub-range of) UTF-32
- return std::copy(begin, end, output);
-}
-
-
-////////////////////////////////////////////////////////////
-template <typename In, typename Out>
-Out Utf<32>::ToAnsi(In begin, In end, Out output, char replacement, const std::locale& locale)
-{
- while (begin < end)
- output = EncodeAnsi(*begin++, output, replacement, locale);
-
- return output;
-}
-
-
-////////////////////////////////////////////////////////////
-template <typename In, typename Out>
-Out Utf<32>::ToWide(In begin, In end, Out output, wchar_t replacement)
-{
- while (begin < end)
- output = EncodeWide(*begin++, output, replacement);
-
- return output;
-}
-
-
-////////////////////////////////////////////////////////////
-template <typename In, typename Out>
-Out Utf<32>::ToLatin1(In begin, In end, Out output, char replacement)
-{
- // Latin-1 is directly compatible with Unicode encodings,
- // and can thus be treated as (a sub-range of) UTF-32
- while (begin < end)
- {
- *output++ = *begin < 256 ? static_cast<char>(*begin) : replacement;
- begin++;
- }
-
- return output;
-}
-
-
-////////////////////////////////////////////////////////////
-template <typename In, typename Out>
-Out Utf<32>::ToUtf8(In begin, In end, Out output)
-{
- while (begin < end)
- output = Utf<8>::Encode(*begin++, output);
-
- return output;
-}
-
-////////////////////////////////////////////////////////////
-template <typename In, typename Out>
-Out Utf<32>::ToUtf16(In begin, In end, Out output)
-{
- while (begin < end)
- output = Utf<16>::Encode(*begin++, output);
-
- return output;
-}
-
-
-////////////////////////////////////////////////////////////
-template <typename In, typename Out>
-Out Utf<32>::ToUtf32(In begin, In end, Out output)
-{
- return std::copy(begin, end, output);
-}
-
-
-////////////////////////////////////////////////////////////
-template <typename In>
-Uint32 Utf<32>::DecodeAnsi(In input, const std::locale& locale)
-{
- // On Windows, GCC's standard library (glibc++) has almost
- // no support for Unicode stuff. As a consequence, in this
- // context we can only use the default locale and ignore
- // the one passed as parameter.
-
- #if defined(SFML_SYSTEM_WINDOWS) && /* if Windows ... */ \
- (defined(__GLIBCPP__) || defined (__GLIBCXX__)) && /* ... and standard library is glibc++ ... */ \
- !(defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION)) /* ... and STLPort is not used on top of it */
-
- (void)locale; // to avoid warnings
-
- wchar_t character = 0;
- mbtowc(&character, &input, 1);
- return static_cast<Uint32>(character);
-
- #else
-
- // Get the facet of the locale which deals with character conversion
- const std::ctype<wchar_t>& facet = std::use_facet< std::ctype<wchar_t> >(locale);
-
- // Use the facet to convert each character of the input string
- return static_cast<Uint32>(facet.widen(input));
-
- #endif
-}
-
-
-////////////////////////////////////////////////////////////
-template <typename In>
-Uint32 Utf<32>::DecodeWide(In input)
-{
- // The encoding of wide characters is not well defined and is left to the system;
- // however we can safely assume that it is UCS-2 on Windows and
- // UCS-4 on Unix systems.
- // In both cases, a simple copy is enough (UCS-2 is a subset of UCS-4,
- // and UCS-4 *is* UTF-32).
-
- return input;
-}
-
-
-////////////////////////////////////////////////////////////
-template <typename Out>
-Out Utf<32>::EncodeAnsi(Uint32 codepoint, Out output, char replacement, const std::locale& locale)
-{
- // On Windows, gcc's standard library (glibc++) has almost
- // no support for Unicode stuff. As a consequence, in this
- // context we can only use the default locale and ignore
- // the one passed as parameter.
-
- #if defined(SFML_SYSTEM_WINDOWS) && /* if Windows ... */ \
- (defined(__GLIBCPP__) || defined (__GLIBCXX__)) && /* ... and standard library is glibc++ ... */ \
- !(defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION)) /* ... and STLPort is not used on top of it */
-
- (void)locale; // to avoid warnings
-
- char character = 0;
- if (wctomb(&character, static_cast<wchar_t>(codepoint)) >= 0)
- *output++ = character;
- else if (replacement)
- *output++ = replacement;
-
- return output;
-
- #else
-
- // Get the facet of the locale which deals with character conversion
- const std::ctype<wchar_t>& facet = std::use_facet< std::ctype<wchar_t> >(locale);
-
- // Use the facet to convert each character of the input string
- *output++ = facet.narrow(static_cast<wchar_t>(codepoint), replacement);
-
- return output;
-
- #endif
-}
-
-
-////////////////////////////////////////////////////////////
-template <typename Out>
-Out Utf<32>::EncodeWide(Uint32 codepoint, Out output, wchar_t replacement)
-{
- // The encoding of wide characters is not well defined and is left to the system;
- // however we can safely assume that it is UCS-2 on Windows and
- // UCS-4 on Unix systems.
- // For UCS-2 we need to check if the source characters fits in (UCS-2 is a subset of UCS-4).
- // For UCS-4 we can do a direct copy (UCS-4 *is* UTF-32).
-
- switch (sizeof(wchar_t))
- {
- case 4:
- {
- *output++ = static_cast<wchar_t>(codepoint);
- break;
- }
-
- default:
- {
- if ((codepoint <= 0xFFFF) && ((codepoint < 0xD800) || (codepoint > 0xDFFF)))
- {
- *output++ = static_cast<wchar_t>(codepoint);
- }
- else if (replacement)
- {
- *output++ = replacement;
- }
- break;
- }
- }
-
- return output;
-}