Description
Check for terminal CR or LF and label the ending CRLF, LF, CR, or none, prioritizing the two-character pair.
Text layout distinguishes Unicode characters, encoded bytes, and visual columns. These counts need not agree: a tab depends on its column position, while a newline is a sequence of characters with a particular spelling.
Check for terminal CR or LF and label the ending CRLF, LF, CR, or none, prioritizing the two-character pair.
When to use this tool
Use Line Ending Final Newline Flag when you need one deterministic text-layout or encoding component under the stated counting convention.
How to use the tool and how it works
- Enter text. Use the units and conventions below.
- Run the tool. Correct any format, range, or cross-field input error before interpreting the output.
- Read hasFinalNewline, ending. Inspect hasFinalNewline before interpreting the associated values.
Check for terminal CR or LF and label the ending CRLF, LF, CR, or none, prioritizing the two-character pair.1
| Input field | Meaning and units | Accepted input |
|---|---|---|
| text | Supplied text; only the transformations stated above are applied. | Required. Text; maximum UTF-16 length 8192. |
| Output field | Interpretation | Returned shape |
|---|---|---|
| hasFinalNewline | Has Final Newline | Required. Boolean. |
| ending | Ending | Required. Text; maximum UTF-16 length 8192. |
{
"input": {
"text": "alpha\r\n"
},
"output": {
"hasFinalNewline": true,
"ending": "CRLF"
}
} Limitations and assumptions
- Only the final ending is classified; internal or mixed line endings and text encoding are not inspected.
- 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.
Alternative or Complementary methods
Inspect the final text in the target encoding and renderer when display width or line wrapping matters.
References
Similar or alternative tools
- Hymn Stanza Line Count
Normalize CRLF and CR to LF, split into lines, and remove one final empty split item.
- Text Tab Stop Width
Advance by tabSize - currentColumn modulo tabSize and return the resulting nextColumn.