blob: 14f64e2752992ca49cadb901d84a15213206ace9 [file] [log] [blame]
Philip P. Moltmannd904c1e2018-03-19 09:26:45 -07001// Copyright 2014 PDFium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6
7#ifndef FXBARCODE_DATAMATRIX_BC_HIGHLEVELENCODER_H_
8#define FXBARCODE_DATAMATRIX_BC_HIGHLEVELENCODER_H_
9
10#include <vector>
11
12#include "core/fxcrt/widestring.h"
13
Philip P. Moltmannd904c1e2018-03-19 09:26:45 -070014class CBC_HighLevelEncoder {
15 public:
Haibo Huang49cc9302020-04-27 16:14:24 -070016 enum class Encoding : int8_t {
17 UNKNOWN = -1,
18 ASCII = 0,
19 C40,
20 TEXT,
21 X12,
22 EDIFACT,
23 BASE256,
24 LAST = BASE256,
25 };
Philip P. Moltmannd904c1e2018-03-19 09:26:45 -070026
Haibo Huang49cc9302020-04-27 16:14:24 -070027 CBC_HighLevelEncoder() = delete;
28 ~CBC_HighLevelEncoder() = delete;
Philip P. Moltmannd904c1e2018-03-19 09:26:45 -070029
Haibo Huang49cc9302020-04-27 16:14:24 -070030 // Returns an empty string on failure.
31 static WideString EncodeHighLevel(const WideString& msg);
Philip P. Moltmannd904c1e2018-03-19 09:26:45 -070032
Haibo Huang49cc9302020-04-27 16:14:24 -070033 static Encoding LookAheadTest(const WideString& msg,
34 size_t startpos,
35 Encoding currentMode);
36 static bool IsExtendedASCII(wchar_t ch);
Philip P. Moltmannd904c1e2018-03-19 09:26:45 -070037
Haibo Huang49cc9302020-04-27 16:14:24 -070038 static const wchar_t LATCH_TO_C40 = 230;
39 static const wchar_t LATCH_TO_BASE256 = 231;
40 static const wchar_t UPPER_SHIFT = 235;
41 static const wchar_t LATCH_TO_ANSIX12 = 238;
42 static const wchar_t LATCH_TO_TEXT = 239;
43 static const wchar_t LATCH_TO_EDIFACT = 240;
44 static const wchar_t C40_UNLATCH = 254;
45 static const wchar_t X12_UNLATCH = 254;
Philip P. Moltmannd904c1e2018-03-19 09:26:45 -070046};
47
48#endif // FXBARCODE_DATAMATRIX_BC_HIGHLEVELENCODER_H_