Documentation de SFML 1.6

Attention: cette page se réfère à une ancienne version de SFML. Cliquez ici pour passer à la dernière version.
Unicode.hpp
1 
2 //
3 // SFML - Simple and Fast Multimedia Library
4 // Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)
5 //
6 // This software is provided 'as-is', without any express or implied warranty.
7 // In no event will the authors be held liable for any damages arising from the use of this software.
8 //
9 // Permission is granted to anyone to use this software for any purpose,
10 // including commercial applications, and to alter it and redistribute it freely,
11 // subject to the following restrictions:
12 //
13 // 1. The origin of this software must not be misrepresented;
14 // you must not claim that you wrote the original software.
15 // If you use this software in a product, an acknowledgment
16 // in the product documentation would be appreciated but is not required.
17 //
18 // 2. Altered source versions must be plainly marked as such,
19 // and must not be misrepresented as being the original software.
20 //
21 // 3. This notice may not be removed or altered from any source distribution.
22 //
24 
25 #ifndef SFML_UNICODE_HPP
26 #define SFML_UNICODE_HPP
27 
29 // Headers
31 #include <SFML/Config.hpp>
32 #include <iterator>
33 #include <locale>
34 #include <string>
35 #include <stdlib.h>
36 
37 
38 namespace sf
39 {
44 class SFML_API Unicode
45 {
46 public :
47 
54  typedef std::basic_string<Uint8> UTF8String;
55  typedef std::basic_string<Uint16> UTF16String;
56  typedef std::basic_string<Uint32> UTF32String;
57 
63  class SFML_API Text
64  {
65  public :
66 
71  Text();
72 
79  Text(const char* Str);
80  Text(const wchar_t* Str);
81  Text(const Uint8* Str);
82  Text(const Uint16* Str);
83  Text(const Uint32* Str);
84  Text(const std::string& Str);
85  Text(const std::wstring& Str);
86  Text(const Unicode::UTF8String& Str);
87  Text(const Unicode::UTF16String& Str);
88  Text(const Unicode::UTF32String& Str);
89 
96  operator std::string () const;
97  operator std::wstring () const;
98  operator Unicode::UTF8String () const;
99  operator Unicode::UTF16String () const;
100  operator const Unicode::UTF32String&() const;
101 
102  private :
103 
105  // Data member
107  sf::Unicode::UTF32String myUTF32String;
108  };
109 
123  template <typename In, typename Out>
124  static Out UTF32ToANSI(In Begin, In End, Out Output, char Replacement = '?', const std::locale& Locale = GetDefaultLocale());
125 
138  template <typename In, typename Out>
139  static Out ANSIToUTF32(In Begin, In End, Out Output, const std::locale& Locale = GetDefaultLocale());
140 
153  template <typename In, typename Out>
154  static Out UTF8ToUTF16(In Begin, In End, Out Output, Uint16 Replacement = '?');
155 
168  template <typename In, typename Out>
169  static Out UTF8ToUTF32(In Begin, In End, Out Output, Uint32 Replacement = '?');
170 
183  template <typename In, typename Out>
184  static Out UTF16ToUTF8(In Begin, In End, Out Output, Uint8 Replacement = '?');
185 
198  template <typename In, typename Out>
199  static Out UTF16ToUTF32(In Begin, In End, Out Output, Uint32 Replacement = '?');
200 
213  template <typename In, typename Out>
214  static Out UTF32ToUTF8(In Begin, In End, Out Output, Uint8 Replacement = '?');
215 
228  template <typename In, typename Out>
229  static Out UTF32ToUTF16(In Begin, In End, Out Output, Uint16 Replacement = '?');
230 
240  template <typename In>
241  static std::size_t GetUTF8Length(In Begin, In End);
242 
252  template <typename In>
253  static std::size_t GetUTF16Length(In Begin, In End);
254 
264  template <typename In>
265  static std::size_t GetUTF32Length(In Begin, In End);
266 
267 private :
268 
275  static const std::locale& GetDefaultLocale();
276 
278  // Static member data
280  static const int UTF8TrailingBytes[256];
281  static const Uint32 UTF8Offsets[6];
282  static const Uint8 UTF8FirstBytes[7];
283 };
284 
285 #include <SFML/System/Unicode.inl>
286 
287 } // namespace sf
288 
289 
290 #endif // SFML_UNICODE_HPP