forked from zxing-cpp/zxing-cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTextDecoder.h
More file actions
39 lines (29 loc) · 1.09 KB
/
Copy pathTextDecoder.h
File metadata and controls
39 lines (29 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/*
* Copyright 2016 Nu-book Inc.
*/
// SPDX-License-Identifier: Apache-2.0
#pragma once
#include "CharacterSet.h"
#include <cstddef>
#include <cstdint>
#include <string>
namespace ZXing {
class TextDecoder
{
public:
static CharacterSet DefaultEncoding();
static CharacterSet GuessEncoding(const uint8_t* bytes, size_t length, CharacterSet fallback = DefaultEncoding());
// If `sjisASCII` set then for Shift_JIS maps ASCII directly (straight-thru), i.e. does not map ASCII backslash & tilde
// to Yen sign & overline resp. (JIS X 0201 Roman)
static void Append(std::string& str, const uint8_t* bytes, size_t length, CharacterSet charset, bool sjisASCII = true);
static void Append(std::wstring& str, const uint8_t* bytes, size_t length, CharacterSet charset);
static void AppendLatin1(std::wstring& str, const std::string& latin1) {
auto ptr = (const uint8_t*)latin1.data();
str.append(ptr, ptr + latin1.length());
}
static std::wstring FromLatin1(const std::string& latin1) {
auto ptr = (const uint8_t*)latin1.data();
return std::wstring(ptr, ptr + latin1.length());
}
};
} // ZXing