The next post appears in a Private Message that miskox sent me. I am copying it here because the answer solve a problem that other users may also have.
miskox wrote:Hi again Antonio!
I understand your solution with the ASCII code for a desired character but unfortunately this is not good for me. Let me show you why:
I have this as part of my .bat file. Then I do a FINDSTR for "TTTTT" with /B and put it in a temporary file.
Code: Select all
TTTTTProlet_2+12; ÚÄÄÄÄÄÂÄÄÄÄÄÂÄÄÄÄÄÂÄÄÄÄÄż
TTTTTProlet_2+12; ł ł82 ł 88ł ł;_82_,10,2}_88_,19,2};
TTTTTProlet_2+12; ł Ă ÄÄÄÄÁÄÄÄÄ ´ ł
TTTTTProlet_2+12; ł 83 łłłł 87 ł;_83_,7,2}_87_,22,2};
TTTTTProlet_2+12; ĂÄÄÄÄÄ´ ĂÄÄÄÄÄ´
TTTTTProlet_2+12; ł 84 86 ł;_84_,7,2}_86_,22,2};
TTTTTProlet_2+12; ł ĂÄÄÄ ÄÂDVIG ´ ł
TTTTTProlet_2+12; ł ł 85 ŔÄÄÄÄÄ´ ł;_85_,12,2};
TTTTTProlet_2+12; ł ł ł ł
TTTTTProlet_2+12; ŔÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄŮ
Then I parse each line: tokens=1,2,3. If token3 is empty then I just display token2.
If token3 is not empty then I parse it and check if current appartment number (for example 82 above) is part of the token2 (_82_) then I get this number's offset and length (10 and 2). Then I perform make three variables:
part1=left part (before 82)
part2=appartment number (82)
part3=everything that is after the appartment number (after 82)
then this code is executed:
Code: Select all
colorshow.exe /07 "%part1%" /E0 "%part2%" /07 "%part3%"
I want the appartment number to be highlighted. (depends on the appartment number of the currently selected record in a main file).
So using ASCII codes causes problems because I don't know where these codes (128-255) are.
Aacini wrote:Of course, the exact characters displayed on the screen depends on the current code page, as usual in all Ascii-build programs (as opposed to Unicode-build ones).
Characters displayed on the screen are correct.
So you say there is not way to display these 128-255 codes correctly?
Put this in a file a.a:
Code: Select all
ÚÄÄÄÄÄÂÄÄÄÄÄÂÄÄÄÄÄÂÄÄÄÄÄż
ł ł82 ł 88ł ł
ł Ă ÄÄÄÄÁÄÄÄÄ ´ ł
ł 83 łłłł 87 ł
ĂÄÄÄÄÄ´ ĂÄÄÄÄÄ´
ł 84 86 ł
ł ĂÄÄÄ ÄÂDVIG ´ ł
ł ł 85 ŔÄÄÄÄÄ´ ł
ł ł ł ł
ŔÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄŮ
and now
Code: Select all
┌─────┬─────┬─────┬─────┐
│ │82 │ 88│ │
│ ├ ────┴──── ┤ │
│ 83 ││││ 87 │
├─────┤ ├─────┤
│ 84 86 │
│ ├─── ─┬DVIG ┤ │
│ │ 85 └─────┤ │
│ │ │ │
└─────┴───────────┴─────┘
Thank you.
Saso
Ok. I completed some tests on this topic. As I said you: "the exact characters displayed on the screen depends on the current code page"; this way, the important point here is identify the characters that are
displayed on the screen by ColorShow.exe program in the current code page, right?
To do that, I started with a text file that contain all Ascii printable characters, from 32 to 255, separated in rows of 16 characters each to easily identify them. This is such file as appears in Windows Notepad:
Code: Select all
2- ! #$%&'()*+,-./
3- 0123456789:;<=>?
4- @ABCDEFGHIJKLMNO
5- PQRSTUVWXYZ[\]^_
6- `abcdefghijklmno
7- pqrstuvwxyz{|}~
8- €‚ƒ„…†‡ˆ‰Š‹ŒŽ
9- ‘’“”•–—˜™š›œžŸ
A- ¡¢£¤¥¦§¨©ª«¬®¯
B- °±²³´µ¶·¸¹º»¼½¾¿
C- ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏ
D- ÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞß
E- àáâãäåæçèéêëìíîï
F- ðñòóôõö÷øùúûüýþÿ
... and this is the same file when it is displayed in the screen with TYPE command:
Code: Select all
C:\> type Char256-32.txt
2- ! #$%&'()*+,-./
3- 0123456789:;<=>?
4- @ABCDEFGHIJKLMNO
5- PQRSTUVWXYZ[\]^_
6- `abcdefghijklmno
7- pqrstuvwxyz{|}~⌂
8- ÇüéâäàåçêëèïîìÄÅ
9- ÉæÆôöòûùÿÖÜø£Ø׃
A- áíóúñѪº¿®¬½¼¡«»
B- ░▒▓│┤ÁÂÀ©╣║╗╝¢¥┐
C- └┴┬├─┼ãÃ╚╔╩╦╠═╬¤
D- ðÐÊËÈıÍÎÏ┘┌█▄¦Ì▀
E- ÓßÔÒõÕµþÞÚÛÙýݯ´
F- ±‗¾¶§÷¸°¨·¹³²■
However, we don't care how these characters are displayed by Notepad or TYPE command, but how these characters are displayed
by ColorShow.exe program, right?
Code: Select all
C:\> for /F "delims=" %a in (Char256-32.txt) do @ColorShow "%a" 13 10
2- ! #$%&'()*+,-./
3- 0123456789:;<=>?
4- @ABCDEFGHIJKLMNO
5- PQRSTUVWXYZ[\]^_
6- `abcdefghijklmno
7- pqrstuvwxyz{|}~
8- óÚÔõÓÕþÛÙÞ´¯ý─┼
9- ╔µã¶÷‗¹¨ Í▄°úÏÎâ
A- ßݾ·±Ð¬║┐«¼¢╝í½╗
B- ªªªªª┴┬└®ªª++óÑ+
C- +--+-+Ò├++--ª-+ñ
D- ð╩╦╚i═╬¤++ª_ª╠»
E- Ë▀ÈʧıÁ■Ì┌█┘²¦»┤
F- ¡▒=¥Âº¸©░¿À╣│▓ªá
As we can see, in this screen all line drawing characters appears, although in different positions. If we compare this screen vs. the original file as displayed in Notepad (that is the text editor I use to create these files), we can know what are the
equivalent characters that should be used in order to display a certain character in the screen using ColorShow program.
After that, I copied your "wanted" file into Notepad, that looks like this:
Code: Select all
┌─────┬─────┬─────┬─────┐
│ │82 │ 88│ │
│ ├ ────┴──── ┤ │
│ 83 ││││ 87 │
├─────┤ ├─────┤
│ 84 86 │
│ ├─── ─┬DVIG ┤ │
│ │ 85 └─────┤ │
│ │ │ │
└─────┴───────────┴─────┘
... and then replaced each line-drawing character by the equivalent character after seek it in the
previous screen and copied the
corresponding character from the Char256-32.txt file (as explained before). This is the resulting file, as it appears in Notepad:
Code: Select all
鎎ŽŽŽ¶ŽŽŽŽŽ¶ŽŽŽŽŽ¶ŽŽŽŽŽ¨
ü ü82 ü 88ü ü
ü Ç ŽŽŽŽµŽŽŽŽ ï ü
ü 83 üüüü 87 ü
ÇŽŽŽŽŽï ÇŽŽŽŽŽï
ü 84 86 ü
ü ÇŽŽŽ Ž¶DVIG ï ü
ü ü 85 ·ŽŽŽŽŽï ü
ü ü ü ü
·ŽŽŽŽŽµŽŽŽŽŽŽŽŽŽŽŽµŽŽŽŽŽë
... and this is how the file appears in the screen when it is displayed via TYPE command:
Code: Select all
C:\> type input.txt
ÚÄÄÄÄÄÂÄÄÄÄÄÂÄÄÄÄÄÂÄÄÄÄÄ¿
³ ³82 ³ 88³ ³
³ Ã ÄÄÄÄÁÄÄÄÄ ´ ³
³ 83 ³³³³ 87 ³
ÃÄÄÄÄÄ´ ÃÄÄÄÄÄ´
³ 84 86 ³
³ ÃÄÄÄ ÄÂDVIG ´ ³
³ ³ 85 ÀÄÄÄÄÄ´ ³
³ ³ ³ ³
ÀÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÙ
However (again): we don't care how this file is displayed in Notepad or by TYPE command, but how it is displayed by the ColorShow program:
Code: Select all
C:\> for /F "delims=" %a in (input.txt) do @ColorShow "%a" 13 10
┌─────┬─────┬─────┬─────┐
│ │82 │ 88│ │
│ ├ ────┴──── ┤ │
│ 83 ││││ 87 │
├─────┤ ├─────┤
│ 84 86 │
│ ├─── ─┬DVIG ┤ │
│ │ 85 └─────┤ │
│ │ │ │
└─────┴───────────┴─────┘
After that, I wrote this test Batch file just to complete this answer:
Code: Select all
@echo off
setlocal EnableDelayedExpansion
for /F "delims=" %%A in (input.txt) do (
set "line=%%A"
for /F "tokens=1,2 delims=;" %%a in ("!line:82=;!") do (
if "%%b" equ "" (
colorshow "!line!" 13 10
) else (
set "part1=%%a"
set "part2=82"
set "part3=%%b"
colorshow.exe /07 "!part1!" /E0 "!part2!" /07 "!part3!" 13 10
)
)
)
... and this is the output:
VERY IMPORTANT: I run previous tests using the standard code page in my computer, that is 850. I also did some tests changing the current code page, and I realized that the "frame drawing" characters does NOT appear in all code pages. In particular, it appears in code page 437 in different positions, and some vertical lines does not appear in code page 852. The simplest solution to this point is change code page to 850 before run your program...
Antonio