xref: /aosp_15_r20/external/pdfium/fxbarcode/datamatrix/BC_HighLevelEncoder.h (revision 3ac0a46f773bac49fa9476ec2b1cf3f8da5ec3a4)
1 // Copyright 2014 The PDFium Authors
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 "core/fxcrt/widestring.h"
11 
12 class CBC_HighLevelEncoder {
13  public:
14   enum class Encoding : int8_t {
15     UNKNOWN = -1,
16     ASCII = 0,
17     C40,
18     TEXT,
19     X12,
20     EDIFACT,
21     BASE256,
22     LAST = BASE256,
23   };
24 
25   CBC_HighLevelEncoder() = delete;
26   ~CBC_HighLevelEncoder() = delete;
27 
28   // Returns an empty string on failure.
29   static WideString EncodeHighLevel(const WideString& msg);
30 
31   static Encoding LookAheadTest(const WideString& msg,
32                                 size_t startpos,
33                                 Encoding currentMode);
34   static bool IsExtendedASCII(wchar_t ch);
35 
36   static const wchar_t LATCH_TO_C40 = 230;
37   static const wchar_t LATCH_TO_BASE256 = 231;
38   static const wchar_t UPPER_SHIFT = 235;
39   static const wchar_t LATCH_TO_ANSIX12 = 238;
40   static const wchar_t LATCH_TO_TEXT = 239;
41   static const wchar_t LATCH_TO_EDIFACT = 240;
42   static const wchar_t C40_UNLATCH = 254;
43   static const wchar_t X12_UNLATCH = 254;
44 };
45 
46 #endif  // FXBARCODE_DATAMATRIX_BC_HIGHLEVELENCODER_H_
47