Project Box Draw is the source text of compiled 32bit Windows executable utility which converts codes of Box Drawing characters from OEM encoding to HTML Unicode entities.
I employ this utility to convert schematic images and diagrams created with simple semigraphic capability of plaintext editor (MultiEdit) for publishing on web.
euroasm boxdraw.htm
boxdraw input.txt output.html
EUROASM UNICODE=OFF, boxdraw PROGRAM FORMAT=PE,WIDTH=32,ENTRY=Start: INCLUDEHEAD1 wins.htm, winscon.htm, winapi.htm, winf32.htm, string32.htm, cpuext32.htm [.data] InpFile DS FILE ; Declare FILE structures for input & output: OutFile DS FILE HelpText: ; Message issued when run with incorrect number of parameters. DB 'Program: boxdraw.exe InputFileName OutputFileName',13,10 DB 'Format: 32bit Windows console application',13,10 DB 'Version: %^DATE',13,10 DB 'Licence: Public domain by vitsoft',13,10 DB 'Function: Conversion of box drawing characters from OEM encoding',13,10 DB ' to HTML Unicode entities.',13,10 DB 0 Entity: DB 0x26,'#x????;' ; Question marks in the template &#x????; will be replaced with 4 hexadecimal characters.
ALIGN WORD Table: DW \ 0x2591, \ 0xB0 ░ LIGHT SHADE 0x2592, \ 0xB1 ▒ MEDIUM SHADE 0x2593, \ 0xB2 ▓ DARK SHADE 0x2502, \ 0xB3 │ BOX DRAWINGS LIGHT VERTICAL 0x2524, \ 0xB4 ┤ BOX DRAWINGS LIGHT VERTICAL AND LEFT 0x2561, \ 0xB5 ╡ BOX DRAWINGS LIGHT VERTICAL SINGLE AND LEFT DOUBLE 0x2562, \ 0xB6 ╢ BOX DRAWINGS VERTICAL DOUBLE AND LEFT SINGLE 0x2556, \ 0xB7 ╖ BOX DRAWINGS DOWN DOUBLE AND LEFT SINGLE 0x2555, \ 0xB8 ╕ BOX DRAWINGS DOWN SINGLE AND LEFT DOUBLE 0x2563, \ 0xB9 ╣ BOx DRAWINGS DOUBLE VERTICAL AND LEFT 0x2551, \ 0xBA ║ BOX DRAWINGS DOUBLE VERTICAL 0x2557, \ 0xBB ╗ BOX DRAWINGS DOUBLE DOWN AND LEFT 0x255D, \ 0xBC ╝ BOX DRAWINGS DOUBLE UP AND LEFT 0x255C, \ 0xBD ╜ BOX DRAWINGS UP DOUBLE AND LEFT SINGLE 0x255B, \ 0xBE ╛ BOX DRAWINGS UP SINGLE AND LEFT DOUBLE 0x2510, \ 0xBF ┐ BOX DRAWINGS LIGHT DOWN AND LEFT 0x2514, \ 0xC0 └ BOX DRAWINGS LIGHT UP AND RIGHT 0x2534, \ 0xC1 ┴ BOX DRAWINGS LIGHT UP AND HORIZONTAL 0x252C, \ 0xC2 ┬ BOX DRAWINGS LIGHT DOWN AND HORIZONTAL 0x251C, \ 0xC3 ├ BOX DRAWINGS LIGHT VERTICAL AND LEFT 0x2500, \ 0xC4 ─ BOX DRAWINGS LIGHT HORIZONTAL 0x253C, \ 0xC5 ┼ BOX DRAWINGS LIGHT VERTICAL AND HORIZONTAL 0x255E, \ 0xC6 ╞ BOX DRAWINGS VERTICAL SINGLE AND RIGHT DOUBLE 0x255F, \ 0xC7 ╟ BOX DRAWINGS VERTICAL DOUBLE AND RIGHT SINGLE 0x255A, \ 0xC8 ╚ BOX DRAWINGS DOUBLE UP AND RIGHT 0x2554, \ 0xC9 ╔ BOX DRAWINGS DOUBLE DOWN AND RIGHT 0x2569, \ 0xCA ╩ BOX DRAWINGS DOUBLE UP AND HORIZONTAL 0x2566, \ 0xCB ╦ BOX DRAWINGS DOUBLE DOWN AND HORIZONTAL 0x2560, \ 0xCC ╠ BOX DRAWINGS DOUBLE VERTICAL AND RIGHT 0x2550, \ 0xCD ═ BOX DRAWINGS DOUBLE HORIZONTAL 0x256C, \ 0xCE ╬ BOX DRAWINGS DOUBLE VERTICAL AND HORIZONTAL 0x2567, \ 0xCF ╧ BOX DRAWINGS UP SINGLE AND HORIZONTAL DOUBLE 0x2568, \ 0xD0 ╨ BOX DRAWINGS UP DOUBLE AND HORIZONTAL SINGLE 0x2564, \ 0xD1 ╤ BOX DRAWINGS DOWN SINGLE AND HORIZONTAL DOUBLE 0x2565, \ 0xD2 ╥ BOX DRAWINGS DOWN DOUBLE AND HORIZONTAL SINGLE 0x2559, \ 0xD3 ╙ BOX DRAWINGS UP DOUBLE AND RIGHT SINGLE 0x2558, \ 0xD4 ╘ BOX DRAWINGS UP SINGLE AND RIGHT DOUBLE 0x2552, \ 0xD5 ╒ BOX DRAWINGS DOWN SINGLE AND RIGHT DOUBLE 0x2553, \ 0xD6 ╓ BOX DRAWINGS DOWN DOUBLE AND RIGHT SINGLE 0x256B, \ 0xD7 ╫ BOX DRAWINGS VERTICAL DOUBLE AND HORIYONTAL SINGLE 0x256A, \ 0xD8 ╪ BOX DRAWINGS VERTICAL SINGLE AND HORIZONTAL DOUBLE 0x2518, \ 0xD9 ┘ BOX DRAWINGS LIGHT UP AND LEFT 0x250C, \ 0xDA ┌ BOX DRAWINGS LIGHT DOWN AND RIGHT 0x2588, \ 0xDB █ FULL BLOCK 0x2584, \ 0xDC ▄ LOWER HALF BLOCK 0x258C, \ 0xDD ▌ LEFT HALF BLOCK 0x2590, \ 0xDE ▐ RIGHT HALF BLOCK 0x2580, \ 0xDF ▀ UPPER HALF BLOCK ; %IF SIZE# Table <> 96 %ERROR "Conversion table size is not 96." %ENDIF
[.text] Start: GetArgCount ; Macro from library winapi.htm. JNC OK: ; If number of command-line arguments returned normally. Help: StdOutput HelpText, Handle=STD_ERROR_HANDLE Abort: TerminateProgram Errorlevel=8 BadInput: StdOutput =B'Error reading input file ', InpFile.Name, Eol=Yes, Handle=STD_ERROR_HANDLE JMP Abort: BadOutput:StdOutput =B'Error writing output file ', OutFile.Name, Eol=Yes, Handle=STD_ERROR_HANDLE JMP Abort: OK: CMP ECX,2 ; Two arguments required. JNE Help: GetArg 2 ; ESI,ECX is now OutputFileName. StripQuotes ESI,ECX FileAssign OutFile,ESI,Size=ECX FileStreamCreate OutFile JC BadOutput: GetArg 1 ; ESI,ECX is now InputFileName. StripQuotes ESI,ECX FileAssign InpFile,ESI,Size=ECX FileLoad InpFile ; Read input file to memory, return pointer,size in ESI,EAX. JC BadInput: LEA EDX,[ESI+EAX] ; Input contents is now between ESI..EDX. NextChar: CMP ESI,EDX ; Is the end of input reached? JNB End: ; When all characters were converted. XOR EAX,EAX ; Clear the working register. LODSB CMP AL,0xB0 ; The lowest supported OEM box character. JB Copy: CMP AL,0xDF ; The highest supported OEM box character. JA Copy: LEA EBX,[EAX-0xB0] ; EBX is now 0..0x1F for box characters 0xB0..0xDF. MOV AX,[Table + 2*EBX] ; The actual conversion. StoH Entity+3, Size=4, LeadingZeroes=yes ; Update the variable Entity with 4 hexa chars. FileStreamWrite OutFile,Entity,8 ; Store the converted Entity to output. JMP NextChar: Copy: FileStreamWriteByte OutFile ; Copy ordinary non-box character AL to output. JMP NextChar: End: FileClose InpFile, OutFile TerminateProgram Errorlevel=0 ENDPROGRAM boxdraw