also looking at this
chore(deps): update dependency react to 19.2.7
#2137
222 files
+16350
-1825
Review threads live on the whole diff, not on one commit, so none are shown here - a thread's line means something in the branch's final form, and painting it into an intermediate step would put it on code it is not about.
| @@ -1,33 +1,53 @@ | ||
| 1 | 1 | # CODE128 |
| 2 | 2 | |
| 3 | CODE128 is one of the more versatile barcodes. It has support for all 128 ASCII characters but does also encode numbers efficiently. It has three modes (A/B/C) but can switch between them at any time. CODE128 is the default barcode that barcode will choose if nothing else is specified. | |
| 3 | CODE128 is one of the most versatile barcode formats available. It has full support for all 128 ASCII characters while maintaining efficient number encoding. The format features three modes (A/B/C) and can dynamically switch between them, making it highly adaptable for various use cases. CODE128 is the default format in qrx when no specific format is specified. | |
| 4 | 4 | |
| 5 | ## Supported Modes | |
| 5 | ## Understanding CODE128 Modes | |
| 6 | 6 | |
| 7 | ***Auto (recommended)*** | |
| 7 | CODE128 has three different modes, each optimized for different types of data: | |
| 8 | ||
| 9 | - **Mode A**: Uppercase letters, numbers, and special characters | |
| 10 | - **Mode B**: Upper and lowercase letters, numbers, and special characters | |
| 11 | - **Mode C**: Numbers only (encoded in pairs for maximum density) | |
| 12 | ||
| 13 | [!NOTE] Image needed: Visual comparison of the same data encoded in different modes (A, B, and C) | |
| 14 | ||
| 15 | ## Basic Usage | |
| 16 | ||
| 17 | The simplest way to use CODE128 is to let qrx automatically choose the best mode: | |
| 8 | 18 | |
| 9 | 19 | ```ts |
| 10 | 20 | import { barcode } from '@stacksjs/qrx' |
| 11 | 21 | |
| 12 | barcode('#barcode', 'Example1234') // CODE128 (auto) is the default mode | |
| 13 | barcode('#barcode', 'Example1234', { format: 'CODE128' }) // But you can still specify it | |
| 22 | // Automatic mode (recommended) | |
| 23 | barcode('#barcode', 'Example1234') // CODE128 auto is the default | |
| 24 | barcode('#barcode', 'Example1234', { format: 'CODE128' }) // Explicit format specification | |
| 14 | 25 | ``` |
| 15 | 26 | |
| 16 | ***Forced modes*** | |
| 27 | [!NOTE] Image needed: Result of the above basic examples showing the generated barcodes | |
| 28 | ||
| 29 | ## Force Modes | |
| 17 | 30 | |
| 18 | If the barcode scanner only supports one type of CODE128 you can force that mode. | |
| 31 | Sometimes you may need to force a specific CODE128 mode, particularly when working with barcode scanners that only support certain modes: | |
| 19 | 32 | |
| 20 | 33 | ```ts |
| 21 | 34 | import { barcode } from '@stacksjs/qrx' |
| 22 | 35 | |
| 36 | // Mode A - Uppercase & Control Characters | |
| 23 | 37 | barcode('#barcode', 'EXAMPLE\n1234', { format: 'CODE128A' }) |
| 38 | ||
| 39 | // Mode B - All ASCII Characters | |
| 24 | 40 | barcode('#barcode', 'Example1234', { format: 'CODE128B' }) |
| 41 | ||
| 42 | // Mode C - Numbers Only (most compact) | |
| 25 | 43 | barcode('#barcode', '12345678', { format: 'CODE128C' }) |
| 26 | 44 | ``` |
| 27 | 45 | |
| 28 | ## `ean128` option for CODE128 | |
| 46 | [!NOTE] Image needed: Side-by-side comparison of the same data encoded in each mode | |
| 47 | ||
| 48 | ## GS1-128/EAN-128 Support | |
| 29 | 49 | |
| 30 | Enable encoding CODE128 as GS1-128/EAN-128. | |
| 50 | CODE128 can be encoded as GS1-128 _(formerly known as EAN-128)_ using the `ean128` option: | |
| 31 | 51 | |
| 32 | 52 | ```ts |
| 33 | 53 | import { barcode } from '@stacksjs/qrx' |
| @@ -38,18 +58,85 @@ barcode('#barcode', '12345678', { | ||
| 38 | 58 | }) |
| 39 | 59 | ``` |
| 40 | 60 | |
| 41 | ## Non printable characters | |
| 61 | [!NOTE] Image needed: Comparison of normal CODE128 vs GS1-128 encoding | |
| 42 | 62 | |
| 43 | CODE128 supports all 128 ASCII characters. You can input them in a few ways. | |
| 63 | ## Working with Special Characters | |
| 44 | 64 | |
| 45 | Here are some examples of how to encode *newlines*, *tabs*, and *carriage returns*. | |
| 65 | CODE128 supports the full ASCII character set (0-127). Here are different ways to encode special characters: | |
| 46 | 66 | |
| 47 | 67 | ```ts |
| 48 | 68 | import { barcode } from '@stacksjs/qrx' |
| 49 | 69 | |
| 70 | // Using escape sequences | |
| 50 | 71 | barcode('#barcode', '\n\t\r') |
| 72 | ||
| 73 | // Using hex codes | |
| 51 | 74 | barcode('#barcode', '\x0A\x09\x0D') |
| 75 | ||
| 76 | // Using ASCII values | |
| 52 | 77 | barcode('#barcode', String.fromCharCode(10, 9, 13)) |
| 53 | 78 | ``` |
| 54 | 79 | |
| 55 | For information about all ASCII character, see [ASCII Table](https://www.asciitable.com/). | |
| 80 | [!NOTE] Image needed: Examples of barcodes with special characters encoded | |
| 81 | ||
| 82 | ## Advanced Options | |
| 83 | ||
| 84 | You can customize the appearance of CODE128 barcodes with these options: | |
| 85 | ||
| 86 | ```ts | |
| 87 | import { barcode } from '@stacksjs/qrx' | |
| 88 | ||
| 89 | barcode('#barcode', 'Example1234', { | |
| 90 | format: 'CODE128', | |
| 91 | width: 2, // Width of a single bar | |
| 92 | height: 100, // Height of the barcode | |
| 93 | displayValue: true, // Show the text below the barcode | |
| 94 | fontSize: 20, // Size of the text | |
| 95 | font: 'monospace', // Font family | |
| 96 | textAlign: 'center', // Text alignment (left/center/right) | |
| 97 | textPosition: 'bottom', // Text position (top/bottom) | |
| 98 | background: '#ffffff', // Background color | |
| 99 | lineColor: '#000000', // Barcode color | |
| 100 | }) | |
| 101 | ``` | |
| 102 | ||
| 103 | [!NOTE] Image needed: Examples showing different customization options | |
| 104 | ||
| 105 | ## Best Practices | |
| 106 | ||
| 107 | 1. Mode Selection: | |
| 108 | - Use automatic mode unless you have specific requirements | |
| 109 | - Use Mode C for number-only data for maximum density | |
| 110 | - Use Mode A when uppercase and control characters are needed | |
| 111 | - Use Mode B for mixed-case text | |
| 112 | 2. Data Validation: | |
| 113 | - ```ts | |
| 114 | barcode('#barcode', 'Your Data', { | |
| 115 | format: 'CODE128', | |
| 116 | valid: (valid) => { | |
| 117 | if (!valid) | |
| 118 | console.error('Invalid data for CODE128') | |
| 119 | } | |
| 120 | }) | |
| 121 | ``` | |
| 122 | 3. Error Handling: | |
| 123 | - ```ts | |
| 124 | try { | |
| 125 | barcode('#barcode', 'Your Data', { format: 'CODE128' }) | |
| 126 | } | |
| 127 | catch (error) { | |
| 128 | console.error('Failed to generate barcode:', error) | |
| 129 | } | |
| 130 | ``` | |
| 131 | ||
| 132 | ## Format Specifications | |
| 133 | ||
| 134 | - **Character Set:** Full ASCII (0-127) | |
| 135 | - **Data Length:** Variable | |
| 136 | - **Check Digit:** Modulo 103 | |
| 137 | - **Start/Stop Characters:** Automatically added | |
| 138 | - **Error Detection:** Built-in check character | |
| 139 | ||
| 140 | [!NOTE] Image needed: Diagram showing the structure of a CODE128 barcode | |
| 141 | ||
| 142 | For information about ASCII characters and their codes, see the ASCII Table. | |
| @@ -1,8 +1,19 @@ | ||
| 1 | 1 | # CODE39 |
| 2 | 2 | |
| 3 | CODE39 is an old barcode type that can encode numbers, uppercase letters and a number of special characters (`-`, `.`, `$`, `/`, `+`, `%`, and `space`). It has been a common barcode type in the past but CODE128 is recommended if not for legacy reasons. | |
| 3 | CODE39 (also known as Code 3 of 9) is one of the earliest barcode formats still in use today. While CODE128 is generally recommended for new implementations, CODE39 remains widely used in inventory management, military applications, and automotive industries due to its simplicity and legacy support. | |
| 4 | 4 | |
| 5 | ## Example | |
| 5 | ## Character Set | |
| 6 | ||
| 7 | CODE39 supports: | |
| 8 | ||
| 9 | - Numbers (0-9) | |
| 10 | - Uppercase letters (A-Z) | |
| 11 | - Special characters: `-`, `.`, `$`, `/`, `+`, `%`, `space` | |
| 12 | - Start/Stop characters (`*`) are automatically added | |
| 13 | ||
| 14 | ## Basic Usage | |
| 15 | ||
| 16 | Here's a simple example of generating a CODE39 barcode: | |
| 6 | 17 | |
| 7 | 18 | ```ts |
| 8 | 19 | import { barcode } from '@stacksjs/qrx' |
| @@ -12,11 +23,17 @@ barcode('#barcode', 'CODE39 Barcode', { | ||
| 12 | 23 | }) |
| 13 | 24 | ``` |
| 14 | 25 | |
| 15 |  | |
| 26 | [!NOTE] Image needed: Result of the above basic example showing the generated barcode | |
| 27 | ||
| 28 | ## Checksum Support (Mod43) | |
| 16 | 29 | |
| 17 | ## Mod43 checksum | |
| 30 | CODE39 supports an optional modulo 43 checksum digit for enhanced error detection. When enabled: | |
| 18 | 31 | |
| 19 | Code 39 is sometimes used with an optional modulo 43 check digit. Using it requires this feature to be enabled in the barcode reader. It is enabled by setting the `mod43` option to `true`. | |
| 32 | 1. A check digit is calculated using modulo 43 algorithm | |
| 33 | 2. The check digit is appended to the data | |
| 34 | 3. Barcode scanners must be configured to validate mod43 | |
| 35 | ||
| 36 | Enable the checksum using the `mod43` option: | |
| 20 | 37 | |
| 21 | 38 | ```ts |
| 22 | 39 | import { barcode } from '@stacksjs/qrx' |
| @@ -27,4 +44,101 @@ barcode('#barcode', 'ABCDEFG', { | ||
| 27 | 44 | }) |
| 28 | 45 | ``` |
| 29 | 46 | |
| 30 |  | |
| 47 | [!NOTE] Image needed: Result of the above example showing the generated barcode with checksum digit | |
| 48 | ||
| 49 | ## Customization Options | |
| 50 | ||
| 51 | CODE39 supports all standard customization options: | |
| 52 | ||
| 53 | ```ts | |
| 54 | import { barcode } from '@stacksjs/qrx' | |
| 55 | ||
| 56 | barcode('#barcode', 'CUSTOM39', { | |
| 57 | format: 'CODE39', | |
| 58 | width: 2, // Bar width | |
| 59 | height: 100, // Barcode height | |
| 60 | displayValue: true, // Show text below barcode | |
| 61 | fontSize: 20, // Text size | |
| 62 | font: 'monospace', // Text font | |
| 63 | textAlign: 'center', // Text alignment | |
| 64 | textPosition: 'bottom', // Text position | |
| 65 | background: '#ffffff', // Background color | |
| 66 | lineColor: '#ffffff' // Bar color | |
| 67 | }) | |
| 68 | ``` | |
| 69 | ||
| 70 | ## Technical Specifications | |
| 71 | ||
| 72 | - Type: Discrete, variable-length | |
| 73 | - Character Set: 43 characters (0-9, A-Z, and 7 special characters) | |
| 74 | - Check Digit: Optional (Mod 43) | |
| 75 | - Self-Checking: Yes | |
| 76 | - Length: Variable | |
| 77 | - Error Detection: Basic (improved with Mod 43) | |
| 78 | ||
| 79 | [!NOTE] Image needed: Diagram showing CODE39 barcode structure | |
| 80 | ||
| 81 | ## Common Use Cases | |
| 82 | ||
| 83 | 1. **Military/Government** | |
| 84 | - CAGE (Commercial and Government Entity) codes | |
| 85 | - Department of Defense applications | |
| 86 | 2. **Automotive Industry** | |
| 87 | - Vehicle Identification Numbers (VIN) | |
| 88 | - Part tracking | |
| 89 | 3. **Healthcare** | |
| 90 | - Patient identification | |
| 91 | - Medical equipment tracking | |
| 92 | ||
| 93 | [!NOTE] Image needed: Example of CODE39 in real-world application | |
| 94 | ||
| 95 | ## Advantages and Limitations | |
| 96 | ||
| 97 | ### Advantages | |
| 98 | ||
| 99 | - Simple structure | |
| 100 | - Self-checking | |
| 101 | - Widely supported | |
| 102 | - No special start/stop characters needed | |
| 103 | - Readable even if printed at low density | |
| 104 | ||
| 105 | ### Limitations | |
| 106 | ||
| 107 | - Lower data density than CODE128 | |
| 108 | - Limited character set | |
| 109 | - Larger space requirement | |
| 110 | - No native support for lowercase letters | |
| 111 | ||
| 112 | ## Best Practices | |
| 113 | ||
| 114 | 1. Input Validation | |
| 115 | - Always verify input contains only valid characters | |
| 116 | - Consider using uppercase transformation for input | |
| 117 | 2. Error Handling | |
| 118 | ```ts | |
| 119 | try { | |
| 120 | barcode('#barcode', 'TEST-123', { format: 'CODE39' }) | |
| 121 | } | |
| 122 | catch (error) { | |
| 123 | console.error('Barcode generation failed:', error) | |
| 124 | } | |
| 125 | ``` | |
| 126 | 3. Check Digit Usage | |
| 127 | - Enable mod43 for applications requiring high reliability | |
| 128 | - Ensure scanners are configured correctly for mod43 | |
| 129 | ||
| 130 | ## Migration to CODE128 | |
| 131 | ||
| 132 | If you're considering migrating from CODE39 to CODE128: | |
| 133 | ||
| 134 | ```ts | |
| 135 | // Old CODE39 implementation | |
| 136 | barcode('#barcode', 'LEGACY-123', { format: 'CODE39' }) | |
| 137 | ||
| 138 | // New CODE128 equivalent | |
| 139 | barcode('#barcode', 'LEGACY-123', { format: 'CODE128' }) | |
| 140 | ``` | |
| 141 | ||
| 142 | [!NOTE] Image needed: Side-by-side comparison of CODE39 vs CODE128 | |
| 143 | ||
| 144 | For more information about ASCII characters and their codes, see the ASCII Table. | |