comparison mupdf-source/thirdparty/zxing-cpp/core/src/TextDecoder.h @ 3:2c135c81b16c

MERGE: upstream PyMuPDF 1.26.4 with MuPDF 1.26.7
author Franz Glasner <fzglas.hg@dom66.de>
date Mon, 15 Sep 2025 11:44:09 +0200
parents b50eed0cc0ef
children
comparison
equal deleted inserted replaced
0:6015a75abc2d 3:2c135c81b16c
1 /*
2 * Copyright 2016 Nu-book Inc.
3 */
4 // SPDX-License-Identifier: Apache-2.0
5
6 #pragma once
7
8 #include "CharacterSet.h"
9
10 #include <cstddef>
11 #include <cstdint>
12 #include <string>
13
14 namespace ZXing {
15
16 class TextDecoder
17 {
18 public:
19 static CharacterSet DefaultEncoding();
20 static CharacterSet GuessEncoding(const uint8_t* bytes, size_t length, CharacterSet fallback = DefaultEncoding());
21
22 // If `sjisASCII` set then for Shift_JIS maps ASCII directly (straight-thru), i.e. does not map ASCII backslash & tilde
23 // to Yen sign & overline resp. (JIS X 0201 Roman)
24 static void Append(std::string& str, const uint8_t* bytes, size_t length, CharacterSet charset, bool sjisASCII = true);
25
26 static void Append(std::wstring& str, const uint8_t* bytes, size_t length, CharacterSet charset);
27
28 static void AppendLatin1(std::wstring& str, const std::string& latin1) {
29 auto ptr = (const uint8_t*)latin1.data();
30 str.append(ptr, ptr + latin1.length());
31 }
32
33 static std::wstring FromLatin1(const std::string& latin1) {
34 auto ptr = (const uint8_t*)latin1.data();
35 return std::wstring(ptr, ptr + latin1.length());
36 }
37 };
38
39 } // ZXing