SFML 3.0.0

- Main Page
- Topics
- Namespaces
- Classes
- Files

- File List
- File Members

Loading...
Searching...
No Matches
Utf.hpp
Go to the documentation of this file.
1
2//
3// SFML - Simple and Fast Multimedia Library
4// Copyright (C) 2007-2024 Laurent Gomila (laurent@sfml-dev.org)
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#pragma once
26
28// Headers
30#include <SFML/Config.hpp>
31
32#include <array>
33#include <locale>
34
35#include <cstdint>
36#include <cstdlib>
37
38
39 namespace sf
40{
41 namespace priv
42{
43 template <class InputIt, class OutputIt>
44OutputIt copy(InputIt first, InputIt last, OutputIt dFirst);
45}
46
47 template <unsigned int N>
48 class Utf;
49
54 template <>
55 class Utf<8>
56{
57 public:
72 template <typename In>
73 static In decode(In begin, In end, char32_t& output, char32_t replacement = 0);
74
88 template <typename Out>
89 static Out encode(char32_t input, Out output, std::uint8_t replacement = 0);
90
103 template <typename In>
104 static In next(In begin, In end);
105
119 template <typename In>
120 static std::size_t count(In begin, In end);
121
136 template <typename In, typename Out>
137 static Out fromAnsi(In begin, In end, Out output, const std::locale& locale = {});
138
149 template <typename In, typename Out>
150 static Out fromWide(In begin, In end, Out output);
151
162 template <typename In, typename Out>
163 static Out fromLatin1(In begin, In end, Out output);
164
180 template <typename In, typename Out>
181 static Out toAnsi(In begin, In end, Out output, char replacement = 0, const std::locale& locale = {});
182
194 template <typename In, typename Out>
195 static Out toWide(In begin, In end, Out output, wchar_t replacement = 0);
196
208 template <typename In, typename Out>
209 static Out toLatin1(In begin, In end, Out output, char replacement = 0);
210
226 template <typename In, typename Out>
227 static Out toUtf8(In begin, In end, Out output);
228
239 template <typename In, typename Out>
240 static Out toUtf16(In begin, In end, Out output);
241
252 template <typename In, typename Out>
253 static Out toUtf32(In begin, In end, Out output);
254};
255
260 template <>
261 class Utf<16>
262{
263 public:
278 template <typename In>
279 static In decode(In begin, In end, char32_t& output, char32_t replacement = 0);
280
294 template <typename Out>
295 static Out encode(char32_t input, Out output, char16_t replacement = 0);
296
309 template <typename In>
310 static In next(In begin, In end);
311
325 template <typename In>
326 static std::size_t count(In begin, In end);
327
342 template <typename In, typename Out>
343 static Out fromAnsi(In begin, In end, Out output, const std::locale& locale = {});
344
355 template <typename In, typename Out>
356 static Out fromWide(In begin, In end, Out output);
357
368 template <typename In, typename Out>
369 static Out fromLatin1(In begin, In end, Out output);
370
386 template <typename In, typename Out>
387 static Out toAnsi(In begin, In end, Out output, char replacement = 0, const std::locale& locale = {});
388
400 template <typename In, typename Out>
401 static Out toWide(In begin, In end, Out output, wchar_t replacement = 0);
402
414 template <typename In, typename Out>
415 static Out toLatin1(In begin, In end, Out output, char replacement = 0);
416
427 template <typename In, typename Out>
428 static Out toUtf8(In begin, In end, Out output);
429
445 template <typename In, typename Out>
446 static Out toUtf16(In begin, In end, Out output);
447
458 template <typename In, typename Out>
459 static Out toUtf32(In begin, In end, Out output);
460};
461
466 template <>
467 class Utf<32>
468{
469 public:
485 template <typename In>
486 static In decode(In begin, In end, char32_t& output, char32_t replacement = 0);
487
502 template <typename Out>
503 static Out encode(char32_t input, Out output, char32_t replacement = 0);
504
517 template <typename In>
518 static In next(In begin, In end);
519
532 template <typename In>
533 static std::size_t count(In begin, In end);
534
549 template <typename In, typename Out>
550 static Out fromAnsi(In begin, In end, Out output, const std::locale& locale = {});
551
562 template <typename In, typename Out>
563 static Out fromWide(In begin, In end, Out output);
564
575 template <typename In, typename Out>
576 static Out fromLatin1(In begin, In end, Out output);
577
593 template <typename In, typename Out>
594 static Out toAnsi(In begin, In end, Out output, char replacement = 0, const std::locale& locale = {});
595
607 template <typename In, typename Out>
608 static Out toWide(In begin, In end, Out output, wchar_t replacement = 0);
609
621 template <typename In, typename Out>
622 static Out toLatin1(In begin, In end, Out output, char replacement = 0);
623
634 template <typename In, typename Out>
635 static Out toUtf8(In begin, In end, Out output);
636
647 template <typename In, typename Out>
648 static Out toUtf16(In begin, In end, Out output);
649
665 template <typename In, typename Out>
666 static Out toUtf32(In begin, In end, Out output);
667
681 template <typename In>
682 static char32_t decodeAnsi(In input, const std::locale& locale = {});
683
696 template <typename In>
697 static char32_t decodeWide(In input);
698
714 template <typename Out>
715 static Out encodeAnsi(char32_t codepoint, Out output, char replacement = 0, const std::locale& locale = {});
716
731 template <typename Out>
732 static Out encodeWide(char32_t codepoint, Out output, wchar_t replacement = 0);
733};
734
735// Make type aliases to get rid of the template syntax
736 using Utf8 = Utf<8>;
737 using Utf16 = Utf<16>;
738 using Utf32 = Utf<32>;
739
740} // namespace sf
741
742#include <SFML/System/Utf.inl>
743
744
Config.hpp
sf::Utf< 16 >
Specialization of the Utf template for UTF-16.
Definition Utf.hpp:262
sf::Utf< 16 >::toUtf16
static Out toUtf16(In begin, In end, Out output)
Convert a UTF-16 characters range to UTF-16.
sf::Utf< 16 >::fromWide
static Out fromWide(In begin, In end, Out output)
Convert a wide characters range to UTF-16.
sf::Utf< 16 >::toWide
static Out toWide(In begin, In end, Out output, wchar_t replacement=0)
Convert an UTF-16 characters range to wide characters.
sf::Utf< 16 >::fromLatin1
static Out fromLatin1(In begin, In end, Out output)
Convert a latin-1 (ISO-5589-1) characters range to UTF-16.
sf::Utf< 16 >::fromAnsi
static Out fromAnsi(In begin, In end, Out output, const std::locale &locale={})
Convert an ANSI characters range to UTF-16.
sf::Utf< 16 >::count
static std::size_t count(In begin, In end)
Count the number of characters of a UTF-16 sequence.
sf::Utf< 16 >::toUtf32
static Out toUtf32(In begin, In end, Out output)
Convert a UTF-16 characters range to UTF-32.
sf::Utf< 16 >::toAnsi
static Out toAnsi(In begin, In end, Out output, char replacement=0, const std::locale &locale={})
Convert an UTF-16 characters range to ANSI characters.
sf::Utf< 16 >::next
static In next(In begin, In end)
Advance to the next UTF-16 character.
sf::Utf< 16 >::toLatin1
static Out toLatin1(In begin, In end, Out output, char replacement=0)
Convert an UTF-16 characters range to latin-1 (ISO-5589-1) characters.
sf::Utf< 16 >::decode
static In decode(In begin, In end, char32_t &output, char32_t replacement=0)
Decode a single UTF-16 character.
sf::Utf< 16 >::encode
static Out encode(char32_t input, Out output, char16_t replacement=0)
Encode a single UTF-16 character.
sf::Utf< 16 >::toUtf8
static Out toUtf8(In begin, In end, Out output)
Convert a UTF-16 characters range to UTF-8.
sf::Utf< 32 >
Specialization of the Utf template for UTF-32.
Definition Utf.hpp:468
sf::Utf< 32 >::fromLatin1
static Out fromLatin1(In begin, In end, Out output)
Convert a latin-1 (ISO-5589-1) characters range to UTF-32.
sf::Utf< 32 >::toLatin1
static Out toLatin1(In begin, In end, Out output, char replacement=0)
Convert an UTF-16 characters range to latin-1 (ISO-5589-1) characters.
sf::Utf< 32 >::toWide
static Out toWide(In begin, In end, Out output, wchar_t replacement=0)
Convert an UTF-32 characters range to wide characters.
sf::Utf< 32 >::toUtf8
static Out toUtf8(In begin, In end, Out output)
Convert a UTF-32 characters range to UTF-8.
sf::Utf< 32 >::toUtf16
static Out toUtf16(In begin, In end, Out output)
Convert a UTF-32 characters range to UTF-16.
sf::Utf< 32 >::decodeWide
static char32_t decodeWide(In input)
Decode a single wide character to UTF-32.
sf::Utf< 32 >::fromAnsi
static Out fromAnsi(In begin, In end, Out output, const std::locale &locale={})
Convert an ANSI characters range to UTF-32.
sf::Utf< 32 >::next
static In next(In begin, In end)
Advance to the next UTF-32 character.
sf::Utf< 32 >::decodeAnsi
static char32_t decodeAnsi(In input, const std::locale &locale={})
Decode a single ANSI character to UTF-32.
sf::Utf< 32 >::count
static std::size_t count(In begin, In end)
Count the number of characters of a UTF-32 sequence.
sf::Utf< 32 >::decode
static In decode(In begin, In end, char32_t &output, char32_t replacement=0)
Decode a single UTF-32 character.
sf::Utf< 32 >::toAnsi
static Out toAnsi(In begin, In end, Out output, char replacement=0, const std::locale &locale={})
Convert an UTF-32 characters range to ANSI characters.
sf::Utf< 32 >::encode
static Out encode(char32_t input, Out output, char32_t replacement=0)
Encode a single UTF-32 character.
sf::Utf< 32 >::encodeAnsi
static Out encodeAnsi(char32_t codepoint, Out output, char replacement=0, const std::locale &locale={})
Encode a single UTF-32 character to ANSI.
sf::Utf< 32 >::encodeWide
static Out encodeWide(char32_t codepoint, Out output, wchar_t replacement=0)
Encode a single UTF-32 character to wide.
sf::Utf< 32 >::toUtf32
static Out toUtf32(In begin, In end, Out output)
Convert a UTF-32 characters range to UTF-32.
sf::Utf< 32 >::fromWide
static Out fromWide(In begin, In end, Out output)
Convert a wide characters range to UTF-32.
sf::Utf< 8 >
Specialization of the Utf template for UTF-8.
Definition Utf.hpp:56
sf::Utf< 8 >::toAnsi
static Out toAnsi(In begin, In end, Out output, char replacement=0, const std::locale &locale={})
Convert an UTF-8 characters range to ANSI characters.
sf::Utf< 8 >::next
static In next(In begin, In end)
Advance to the next UTF-8 character.
sf::Utf< 8 >::decode
static In decode(In begin, In end, char32_t &output, char32_t replacement=0)
Decode a single UTF-8 character.
sf::Utf< 8 >::fromAnsi
static Out fromAnsi(In begin, In end, Out output, const std::locale &locale={})
Convert an ANSI characters range to UTF-8.
sf::Utf< 8 >::toUtf32
static Out toUtf32(In begin, In end, Out output)
Convert a UTF-8 characters range to UTF-32.
sf::Utf< 8 >::fromLatin1
static Out fromLatin1(In begin, In end, Out output)
Convert a latin-1 (ISO-5589-1) characters range to UTF-8.
sf::Utf< 8 >::toUtf16
static Out toUtf16(In begin, In end, Out output)
Convert a UTF-8 characters range to UTF-16.
sf::Utf< 8 >::fromWide
static Out fromWide(In begin, In end, Out output)
Convert a wide characters range to UTF-8.
sf::Utf< 8 >::toWide
static Out toWide(In begin, In end, Out output, wchar_t replacement=0)
Convert an UTF-8 characters range to wide characters.
sf::Utf< 8 >::toLatin1
static Out toLatin1(In begin, In end, Out output, char replacement=0)
Convert an UTF-8 characters range to latin-1 (ISO-5589-1) characters.
sf::Utf< 8 >::toUtf8
static Out toUtf8(In begin, In end, Out output)
Convert a UTF-8 characters range to UTF-8.
sf::Utf< 8 >::count
static std::size_t count(In begin, In end)
Count the number of characters of a UTF-8 sequence.
sf::Utf< 8 >::encode
static Out encode(char32_t input, Out output, std::uint8_t replacement=0)
Encode a single UTF-8 character.
sf::Utf
Utility class providing generic functions for UTF conversions.
Definition Utf.hpp:48
sf
Definition AudioResource.hpp:36