00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00024
00025 #ifndef SFML_UTF_HPP
00026 #define SFML_UTF_HPP
00027
00029
00031 #include <SFML/Config.hpp>
00032 #include <algorithm>
00033 #include <locale>
00034 #include <string>
00035 #include <cstdlib>
00036
00037
00038 namespace sf
00039 {
00040 template <unsigned int N>
00041 class Utf;
00042
00047 template <>
00048 class Utf<8>
00049 {
00050 public :
00051
00066 template <typename In>
00067 static In Decode(In begin, In end, Uint32& output, Uint32 replacement = 0);
00068
00082 template <typename Out>
00083 static Out Encode(Uint32 input, Out output, Uint8 replacement = 0);
00084
00097 template <typename In>
00098 static In Next(In begin, In end);
00099
00113 template <typename In>
00114 static std::size_t Count(In begin, In end);
00115
00130 template <typename In, typename Out>
00131 static Out FromAnsi(In begin, In end, Out output, const std::locale& locale = std::locale());
00132
00143 template <typename In, typename Out>
00144 static Out FromWide(In begin, In end, Out output);
00145
00157 template <typename In, typename Out>
00158 static Out FromLatin1(In begin, In end, Out output);
00159
00175 template <typename In, typename Out>
00176 static Out ToAnsi(In begin, In end, Out output, char replacement = 0, const std::locale& locale = std::locale());
00177
00189 template <typename In, typename Out>
00190 static Out ToWide(In begin, In end, Out output, wchar_t replacement = 0);
00191
00203 template <typename In, typename Out>
00204 static Out ToLatin1(In begin, In end, Out output, char replacement = 0);
00205
00221 template <typename In, typename Out>
00222 static Out ToUtf8(In begin, In end, Out output);
00223
00234 template <typename In, typename Out>
00235 static Out ToUtf16(In begin, In end, Out output);
00236
00247 template <typename In, typename Out>
00248 static Out ToUtf32(In begin, In end, Out output);
00249 };
00250
00255 template <>
00256 class Utf<16>
00257 {
00258 public :
00259
00274 template <typename In>
00275 static In Decode(In begin, In end, Uint32& output, Uint32 replacement = 0);
00276
00290 template <typename Out>
00291 static Out Encode(Uint32 input, Out output, Uint16 replacement = 0);
00292
00305 template <typename In>
00306 static In Next(In begin, In end);
00307
00321 template <typename In>
00322 static std::size_t Count(In begin, In end);
00323
00338 template <typename In, typename Out>
00339 static Out FromAnsi(In begin, In end, Out output, const std::locale& locale = std::locale());
00340
00351 template <typename In, typename Out>
00352 static Out FromWide(In begin, In end, Out output);
00353
00365 template <typename In, typename Out>
00366 static Out FromLatin1(In begin, In end, Out output);
00367
00383 template <typename In, typename Out>
00384 static Out ToAnsi(In begin, In end, Out output, char replacement = 0, const std::locale& locale = std::locale());
00385
00397 template <typename In, typename Out>
00398 static Out ToWide(In begin, In end, Out output, wchar_t replacement = 0);
00399
00411 template <typename In, typename Out>
00412 static Out ToLatin1(In begin, In end, Out output, char replacement = 0);
00413
00424 template <typename In, typename Out>
00425 static Out ToUtf8(In begin, In end, Out output);
00426
00442 template <typename In, typename Out>
00443 static Out ToUtf16(In begin, In end, Out output);
00444
00455 template <typename In, typename Out>
00456 static Out ToUtf32(In begin, In end, Out output);
00457 };
00458
00463 template <>
00464 class Utf<32>
00465 {
00466 public :
00467
00483 template <typename In>
00484 static In Decode(In begin, In end, Uint32& output, Uint32 replacement = 0);
00485
00500 template <typename Out>
00501 static Out Encode(Uint32 input, Out output, Uint32 replacement = 0);
00502
00515 template <typename In>
00516 static In Next(In begin, In end);
00517
00530 template <typename In>
00531 static std::size_t Count(In begin, In end);
00532
00547 template <typename In, typename Out>
00548 static Out FromAnsi(In begin, In end, Out output, const std::locale& locale = std::locale());
00549
00560 template <typename In, typename Out>
00561 static Out FromWide(In begin, In end, Out output);
00562
00574 template <typename In, typename Out>
00575 static Out FromLatin1(In begin, In end, Out output);
00576
00592 template <typename In, typename Out>
00593 static Out ToAnsi(In begin, In end, Out output, char replacement = 0, const std::locale& locale = std::locale());
00594
00606 template <typename In, typename Out>
00607 static Out ToWide(In begin, In end, Out output, wchar_t replacement = 0);
00608
00620 template <typename In, typename Out>
00621 static Out ToLatin1(In begin, In end, Out output, char replacement = 0);
00622
00633 template <typename In, typename Out>
00634 static Out ToUtf8(In begin, In end, Out output);
00635
00646 template <typename In, typename Out>
00647 static Out ToUtf16(In begin, In end, Out output);
00648
00664 template <typename In, typename Out>
00665 static Out ToUtf32(In begin, In end, Out output);
00666
00680 template <typename In>
00681 static Uint32 DecodeAnsi(In input, const std::locale& locale = std::locale());
00682
00695 template <typename In>
00696 static Uint32 DecodeWide(In input);
00697
00713 template <typename Out>
00714 static Out EncodeAnsi(Uint32 codepoint, Out output, char replacement = 0, const std::locale& locale = std::locale());
00715
00730 template <typename Out>
00731 static Out EncodeWide(Uint32 codepoint, Out output, wchar_t replacement = 0);
00732 };
00733
00734 #include <SFML/System/Utf.inl>
00735
00736
00737 typedef Utf<8> Utf8;
00738 typedef Utf<16> Utf16;
00739 typedef Utf<32> Utf32;
00740
00741 }
00742
00743
00744 #endif // SFML_UTF_HPP
00745
00746