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 
14 class CBC_HighLevelEncoder {
15  public:
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   };
26 
27   CBC_HighLevelEncoder() = delete;
28   ~CBC_HighLevelEncoder() = delete;
29 
30   // Returns an empty string on failure.
31   static WideString EncodeHighLevel(const WideString& msg);
32 
33   static Encoding LookAheadTest(const WideString& msg,
34                                 size_t startpos,
35                                 Encoding currentMode);
36   static bool IsExtendedASCII(wchar_t ch);
37 
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;
46 };
47 
48 #endif  // FXBARCODE_DATAMATRIX_BC_HIGHLEVELENCODER_H_
49