Description
Count Unicode code points in each line using Array.from.
Specimen labels must fit a physical medium, while software can count characters by several conventions. Unicode code points, grapheme clusters, rendered glyph widths and actual printed columns need not agree.
Count Unicode code points in each line using Array.from.
When to use this tool
Use Entomology Specimen Pin Label Budget when checking a label against caller-supplied code-point and line budgets.
How to use the tool and how it works
- Enter lines, maximumColumns, maximumLines. Use the units and conventions below.
- Run the tool. Correct any format, range, or cross-field input error before interpreting the output.
- Read lineCount, longestLine, fits. Inspect fits before interpreting the associated values.
Require positive whole maximumColumns and maximumLines. Count Unicode code points in each line using Array.from. Return lineCount, longestLine (zero for no lines), and fits when both the line count and every code-point width fit the supplied bounds.1
| Input field | Meaning and units | Accepted input |
|---|---|---|
| lines | Lines | Required. Array of text; maximum UTF-16 length 8192; maximum items 256. |
| maximumColumns | Code-point budget per supplied line, not rendered glyph or display-cell width. | Required. Safe integer; minimum 1. |
| maximumLines | Maximum Lines | Required. Safe integer; minimum 1. |
| Output field | Interpretation | Returned shape |
|---|---|---|
| lineCount | Line Count | Required. Safe integer. |
| longestLine | Longest Line | Required. Safe integer. |
| fits | Fits | Required. Boolean. |
{
"input": {
"lines": [
"Species A",
"Site 2"
],
"maximumColumns": 12,
"maximumLines": 3
},
"output": {
"lineCount": 2,
"longestLine": 9,
"fits": true
}
} Limitations and assumptions
- Code points are not grapheme clusters, printed glyph widths or terminal display cells. No wrapping, font measurement or label-content validation occurs.
- Inputs must satisfy both the field types and the cross-field conditions above. Invalid input causes an error; a successful false flag or documented placeholder is a different result.
- Numeric calculations use binary floating point unless exact decimal-integer arithmetic is explicitly stated. No hidden measurement tolerance or decimal rounding is added; nonfinite or out-of-contract results are rejected. Numeric signed-zero results are exported as zero.
Alternative or Complementary methods
Measure the actual font and label layout when physical printing fit matters, and review required specimen information separately.
References
Similar or alternative tools
- Base N Fixed Width Left Padding Count
Pad encoded text to a supplied code-point width with an explicit one-code-point zero symbol.
- Endodontic Instrument Tip Code Source
The remaining tipCode must be exactly three ASCII digits.