constants.js 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. // constants for internal usage
  2. export const SET_A = 0;
  3. export const SET_B = 1;
  4. export const SET_C = 2;
  5. // Special characters
  6. export const SHIFT = 98;
  7. export const START_A = 103;
  8. export const START_B = 104;
  9. export const START_C = 105;
  10. export const MODULO = 103;
  11. export const STOP = 106;
  12. export const FNC1 = 207;
  13. // Get set by start code
  14. export const SET_BY_CODE = {
  15. [START_A]: SET_A,
  16. [START_B]: SET_B,
  17. [START_C]: SET_C,
  18. };
  19. // Get next set by code
  20. export const SWAP = {
  21. 101: SET_A,
  22. 100: SET_B,
  23. 99: SET_C,
  24. };
  25. export const A_START_CHAR = String.fromCharCode(208); // START_A + 105
  26. export const B_START_CHAR = String.fromCharCode(209); // START_B + 105
  27. export const C_START_CHAR = String.fromCharCode(210); // START_C + 105
  28. // 128A (Code Set A)
  29. // ASCII characters 00 to 95 (0–9, A–Z and control codes), special characters, and FNC 1–4
  30. export const A_CHARS = "[\x00-\x5F\xC8-\xCF]";
  31. // 128B (Code Set B)
  32. // ASCII characters 32 to 127 (0–9, A–Z, a–z), special characters, and FNC 1–4
  33. export const B_CHARS = "[\x20-\x7F\xC8-\xCF]";
  34. // 128C (Code Set C)
  35. // 00–99 (encodes two digits with a single code point) and FNC1
  36. export const C_CHARS = "(\xCF*[0-9]{2}\xCF*)";
  37. // CODE128 includes 107 symbols:
  38. // 103 data symbols, 3 start symbols (A, B and C), and 1 stop symbol (the last one)
  39. // Each symbol consist of three black bars (1) and three white spaces (0).
  40. export const BARS = [
  41. 11011001100, 11001101100, 11001100110, 10010011000, 10010001100,
  42. 10001001100, 10011001000, 10011000100, 10001100100, 11001001000,
  43. 11001000100, 11000100100, 10110011100, 10011011100, 10011001110,
  44. 10111001100, 10011101100, 10011100110, 11001110010, 11001011100,
  45. 11001001110, 11011100100, 11001110100, 11101101110, 11101001100,
  46. 11100101100, 11100100110, 11101100100, 11100110100, 11100110010,
  47. 11011011000, 11011000110, 11000110110, 10100011000, 10001011000,
  48. 10001000110, 10110001000, 10001101000, 10001100010, 11010001000,
  49. 11000101000, 11000100010, 10110111000, 10110001110, 10001101110,
  50. 10111011000, 10111000110, 10001110110, 11101110110, 11010001110,
  51. 11000101110, 11011101000, 11011100010, 11011101110, 11101011000,
  52. 11101000110, 11100010110, 11101101000, 11101100010, 11100011010,
  53. 11101111010, 11001000010, 11110001010, 10100110000, 10100001100,
  54. 10010110000, 10010000110, 10000101100, 10000100110, 10110010000,
  55. 10110000100, 10011010000, 10011000010, 10000110100, 10000110010,
  56. 11000010010, 11001010000, 11110111010, 11000010100, 10001111010,
  57. 10100111100, 10010111100, 10010011110, 10111100100, 10011110100,
  58. 10011110010, 11110100100, 11110010100, 11110010010, 11011011110,
  59. 11011110110, 11110110110, 10101111000, 10100011110, 10001011110,
  60. 10111101000, 10111100010, 11110101000, 11110100010, 10111011110,
  61. 10111101110, 11101011110, 11110101110, 11010000100, 11010010000,
  62. 11010011100, 1100011101011
  63. ];