Philip P. Moltmann | d904c1e | 2018-03-19 09:26:45 -0700 | [diff] [blame] | 1 | // 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. Moltmann | d904c1e | 2018-03-19 09:26:45 -0700 | [diff] [blame] | 14 | class CBC_HighLevelEncoder { |
| 15 | public: |
Haibo Huang | 49cc930 | 2020-04-27 16:14:24 -0700 | [diff] [blame] | 16 | 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. Moltmann | d904c1e | 2018-03-19 09:26:45 -0700 | [diff] [blame] | 26 | |
Haibo Huang | 49cc930 | 2020-04-27 16:14:24 -0700 | [diff] [blame] | 27 | CBC_HighLevelEncoder() = delete; |
| 28 | ~CBC_HighLevelEncoder() = delete; |
Philip P. Moltmann | d904c1e | 2018-03-19 09:26:45 -0700 | [diff] [blame] | 29 | |
Haibo Huang | 49cc930 | 2020-04-27 16:14:24 -0700 | [diff] [blame] | 30 | // Returns an empty string on failure. |
| 31 | static WideString EncodeHighLevel(const WideString& msg); |
Philip P. Moltmann | d904c1e | 2018-03-19 09:26:45 -0700 | [diff] [blame] | 32 | |
Haibo Huang | 49cc930 | 2020-04-27 16:14:24 -0700 | [diff] [blame] | 33 | static Encoding LookAheadTest(const WideString& msg, |
| 34 | size_t startpos, |
| 35 | Encoding currentMode); |
| 36 | static bool IsExtendedASCII(wchar_t ch); |
Philip P. Moltmann | d904c1e | 2018-03-19 09:26:45 -0700 | [diff] [blame] | 37 | |
Haibo Huang | 49cc930 | 2020-04-27 16:14:24 -0700 | [diff] [blame] | 38 | 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. Moltmann | d904c1e | 2018-03-19 09:26:45 -0700 | [diff] [blame] | 46 | }; |
| 47 | |
| 48 | #endif // FXBARCODE_DATAMATRIX_BC_HIGHLEVELENCODER_H_ |