New file format samples · KcsDev1982/sunbelt-plb-samples@dde89e5 · GitHub
Skip to content

Commit dde89e5

Browse files
committed
New file format samples
Samples to detect files encoding and convert UTF16 data
1 parent 5adc467 commit dde89e5

3 files changed

Lines changed: 80 additions & 0 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions

files/findfmt.pls

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
*---------------------------------------------------------------
2+
.
3+
. Program Name: findfmt.pls
4+
. Description: Find the format for a text file using Byte Order Marks
5+
.
6+
. Revision History:
7+
.
8+
. Date: 07/29/2025
9+
. Original code
10+
.
11+
file FILE
12+
bom1 INTEGER 1
13+
bom2 INTEGER 1
14+
bom3 INTEGER 1
15+
bom4 INTEGER 1
16+
fileName DIM 80
17+
seq FORM "-1"
18+
19+
KEYIN *ES, "Enter file name: ",fileName
20+
OPEN file,fileName,Read
21+
READ file,Seq;*ABSON,bom1,bom2,bom3,bom4
22+
CLOSE file
23+
24+
IF (bom1 == 0xFF AND bom2 == 0XFE AND bom3 == 0 AND bom4 == 0)
25+
DISPLAY "File Format: UTF-32 little-endian"
26+
ELSEIF (bom1 == 0 AND bom2 == 0 AND bom3 == 0xFE AND bom4 == 0XFF)
27+
DISPLAY "File Format: UTF-32 big-endian"
28+
ELSEIF (bom1 == 0xFF AND bom2 == 0XFE)
29+
DISPLAY "File Format: UTF-16 little-endian"
30+
ELSEIF (bom1 == 0xFE AND bom2 == 0XFF)
31+
DISPLAY "File Format: UTF-16 big-endian"
32+
ELSEIF (bom1 == 0xEF AND bom2 == 0xBB AND bom3 == 0xBF )
33+
DISPLAY "File Format: UTF-8"
34+
ELSE
35+
DISPLAY "File Format: ASCII"
36+
ENDIF
37+
KEYIN "Done: ",fileName

files/fixutf16.pls

Lines changed: 42 additions & 0 deletions

0 commit comments

Comments
 (0)