Block chars and source in UTF8

328 views
Skip to first unread message

Hazael

unread,
Mar 3, 2020, 9:21:43 AM3/3/20
to Harbour Users
Hi all,

How can I show block chars in a UTF8 source code?
The result is not as expected (to show the block chars...)

Example:


/* Save this file in UTF-8 format */

REQUEST HB_CODEPAGE_FRISO

PROCEDURE Main()

   hb_cdpSelect( 'FRISO' )

   ? CHR( 176 ), CHR( 177 ), CHR( 178 )
   ?
   ? '░''▒''▓'
   ?
   ? hb_UTF8ToStr( CHR( 176 ) ), hb_UTF8ToStr( CHR( 177 ) ), hb_UTF8ToStr( CHR( 178 ) )
   ?
   ? hb_UTF8ToStr( '░' ), hb_UTF8ToStr( '▒' ), hb_UTF8ToStr( '▓' )
   ?
   ? hb_UTF8ToStrBox( CHR( 176 ) ), hb_UTF8ToStrBox( CHR( 177 ) ), hb_UTF8ToStrBox( CHR( 178 ) )
   ?
   ? hb_UTF8ToStrBox( '░' ), hb_UTF8ToStrBox( '▒' ), hb_UTF8ToStrBox( '▓' )
   ?
   WAIT

RETURN


Test.7z
image.jpg

mstuff kstuff

unread,
Mar 3, 2020, 11:07:02 AM3/3/20
to Harbour Users
 Hazael,

I use notepad2 as my source editor.

If I want a high bit character in there, I use the alt key.
Hold down the Alt key and hit 1 then 7 then 6 then release the Alt key.
It should show a ░.

Mike

Hazael

unread,
Mar 3, 2020, 11:38:58 AM3/3/20
to Harbour Users
Hi Mike,

That is not the problem I have.
I use any editor - including notepad2.
The problem is to show the block chars in the application I build with Harbour.
Did you try the test code I sent?


mstuff kstuff

unread,
Mar 3, 2020, 7:47:25 PM3/3/20
to Harbour Users
Hazael,

You may want to check out:

hb_Translate()   ( sData, sCodepageIN, sCodepageOUT )
Translates a string from one code page to the other

hb_cdpTerm() cCPID returns terminal's code-page ID.
hb_cdpOS() cCPID  returns O/S code-page ID.


It depends that your output is going to.
My code page input is hb EN  but, output is to ms cp1252.

Mike

gvar...@gmail.com

unread,
Mar 4, 2020, 9:15:26 AM3/4/20
to Harbour Users
Hi:
This is rare, if I open the Harbor ChangeLog.txt file and the test.prg sent with Notepad ++ shows different, despite having the same UTF-8 encoding.
If I copy the content of test.prg and paste it in ChangeLog.txt the characters are displayed correctly.
What additional attributes can ChangeLog.txt have to display the characters correctly?

utf.jpg

Hazael

unread,
Mar 4, 2020, 9:46:13 AM3/4/20
to Harbour Users
IMHO it is just a question of the fonts you are using in Notepad++
According to my observation you have one font in the left (for TXT files) and other for source code (for PRG files).

wanst...@gmail.com

unread,
Mar 8, 2020, 9:45:55 PM3/8/20
to Harbour Users
Comming back to the initial question... any clue how to show block chars on the screen from a source file in UTF-8?

Thank you for any help.

wanst...@gmail.com

unread,
Mar 9, 2020, 9:10:07 PM3/9/20
to Harbour Users
I am happy I found the solution:

/* Save this file in UTF-8 format */

#define B_SINGLE        ( Chr( 218 ) + Chr( 196 ) + Chr( 191 ) + Chr( 179 ) + ; /* "┌─┐│┘─└│" */
                          Chr( 217 ) + Chr( 196 ) + Chr( 192 ) + Chr( 179 ) )

#define HB_B_SINGLE_UNI       hb_UTF8ToStrBox( "┌─┐│┘─└│" )

#define B_THIN          ( Chr( 219 ) + Chr( 223 ) + Chr( 219 ) + Chr( 219 ) + ;
                          Chr( 219 ) + Chr( 220 ) + Chr( 219 ) + Chr( 219 ) )

#define B_FAT           ( Chr( 219 ) + Chr( 219 ) + Chr( 219 ) + Chr( 219 ) + ;
                          Chr( 219 ) + Chr( 219 ) + Chr( 219 ) + Chr( 219 ) )

REQUEST HB_CODEPAGE_FRISO


PROCEDURE Main()

   hb_cdpSelect( 'FRISO' )

   SETMODE( 40,132 )

   hb_DispOutAtBox( 12,12, CHR( 176 ) + CHR( 177 ) + CHR( 178 ) + CHR( 219 ) )
   
   hb_DispBox( 15,5,35,125, B_FAT )
   hb_DispBox( 17,7,33,123, B_THIN )
   hb_DispBox( 19,9,31,121, B_SINGLE )
   hb_DispBox( 21,11,29,119, HB_B_SINGLE_UNI )
   WAIT

RETURN

tarpauwatratar

unread,
Mar 11, 2020, 10:02:07 AM3/11/20
to Harbour Users
Look at box.ch:

/* #defines for DispBox() */


/* Single-line */

#define B_SINGLE        ( Chr( 218 ) + Chr( 196 ) + Chr( 191 ) + Chr( 179 ) + ; /* "┌─┐│┘─└│" */
                         
Chr( 217 ) + Chr( 196 ) + Chr( 192 ) + Chr( 179 ) )


/* Double-line */
#define B_DOUBLE        ( Chr( 201 ) + Chr( 205 ) + Chr( 187 ) + Chr( 186 ) + ; /* "╔═╗║╝═╚║" */
                         
Chr( 188 ) + Chr( 205 ) + Chr( 200 ) + Chr( 186 ) )


/* Single-line top, double-line sides */
#define B_SINGLE_DOUBLE ( Chr( 214 ) + Chr( 196 ) + Chr( 183 ) + Chr( 186 ) + ; /* "╓─╖║╜─╙║" */
                         
Chr( 189 ) + Chr( 196 ) + Chr( 211 ) + Chr( 186 ) )


/* Double-line top, single-line sides */
#define B_DOUBLE_SINGLE ( Chr( 213 ) + Chr( 205 ) + Chr( 184 ) + Chr( 179 ) + ; /* "╒═╕│╛═╘│" */
                         
Chr( 190 ) + Chr( 205 ) + Chr( 212 ) + Chr( 179 ) )


#define HB_B_SINGLE_UNI        hb_UTF8ToStrBox( "┌─┐│┘─└│" )
#define HB_B_DOUBLE_UNI        hb_UTF8ToStrBox( "╔═╗║╝═╚║" )
#define HB_B_SINGLE_DOUBLE_UNI hb_UTF8ToStrBox( "╓─╖║╜─╙║" )
#define HB_B_DOUBLE_SINGLE_UNI hb_UTF8ToStrBox( "╒═╕│╛═╘│" )



Reply all
Reply to author
Forward
0 new messages