Announcement

Collapse
No announcement yet.

Displaying Character with Indices > 255 (&hFF)

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
    Gösta H. Lovgren-2
    Member

  • Gösta H. Lovgren-2
    replied
    Originally posted by Laurence Jackson View Post
    ...
    With these changes, the file comes up correctly in Windows XP Notepad too.
    Thanks LJ, your changes worked a charm and as advertised. UltraEdit does load unicode fine (and shows hexes) and does NotePad. Oddly NoteTabPro (my all time long time favorite hands down text editor) does not. Oh well ....

    Note I was tempted to add colors to the two buttons {grin}. Maybe tomorrow.

    ===============================================
    It is dangerous to be right in matters
    on which the established authorities are wrong.
    ~ Voltaire
    ===============================================

    Leave a comment:

  • Laurence Jackson
    Member

  • Laurence Jackson
    replied
    Playing around a little more, these are the changes you need to make (marked with <---):

    Code:
    Macro Uni_Save_Dave
    '  Local fn As Long
    '  Local fl, Ulf As String
      fn = FreeFile
      fl$ = CurDir$ & "\Uni_Test.txt"
      Kill fl$ 'previous run
      Open fl$ For Binary As #fn
      Seek #fn, 1 'Lof(#fn) + 1
    '
      Ulf$ = UCode$($CrLf) 'line feed <--- change
      pf_Dave chr$(&HFF) + chr$(&HFE) '<--- add
      'pf_Dave  Ulf$  'line feed needed as simple pf just doesn't work like it does in ASCII
      pf_Dave UCode$(Space$(20) & "Unicodes Display") & Ulf$ ') <--- error
      pf_Dave UCode$(Space$(20) & Date$ & " " & Time$) & Ulf$  'so as to differentiate between runs
      pf_Dave UCode$(hdr$) & Ulf$ 'does not work
    '
      For ctr = LBound(Id_Uni_Codes()) To UBound(Id_Uni_Codes())
          Pf_Dave  ControlGetTextUnicode(CB.Hndl, Id_Uni_Codes(ctr)) 
          pf_Dave  Ulf$  'line feed needed as simple pf just doesn't work like it does in ASCII
      Next ctr
      Close fn 
    End Macro
    Found a small error in there too. Ulf$ (already in unicode) was included in an ANSI to unicode conversion.

    With these changes, the file comes up correctly in Windows XP Notepad too.

    Leave a comment:

  • Laurence Jackson
    Member

  • Laurence Jackson
    replied
    Gösta, your activity in an old thread of mine has woken me up (I haven't been around much lately because a big project's been keeping me busy). I chanced on this thread which is interesting to me in a "no immediate application" kind of way, and here you are again!

    I was struck by your reference to UltraEdit and you wishing that you could use it to view and edit a unicode file. I use UltraEdit and could have sworn that it is unicode-capable. It is, but it needs a standard unicode signature at the beginning of the file to auto-detect that it's dealing with unicode. That is, the file should start with the byte pair FFh, FEh (assuming that the unicode values are in Intel little-endian format). Put that in and UltraEdit displays your file perfectly, except that UltraEdit detects the file as a Mac file because lines are terminated with CR only. Change that to CR-LF and the file is detected as a "DOS" file.

    So, having got that off my chest, I'll go back and check out the posted code in more detail!

    Leave a comment:

  • colin glenn
    Member

  • colin glenn
    replied
    Originally posted by Gösta H. Lovgren-2 View Post
    The program uses the Consolas font (48 ppt). My bet is that it's not installed on your computer.Change the
    Code:
      Dialog Font "Consolas", 48 '48 fits 8 Japanese chars on 800 wd screen nicely
    in PBMain to another font and recompile.
    Changed font to one which I know is unicode and it works, thanks for the pointer at the problem. Now to determine which character glyphs are valid.
    colin glenn
    Member
    Last edited by colin glenn; 29 May 2009, 11:40 PM.

    Leave a comment:

  • Gösta H. Lovgren-2
    Member

  • Gösta H. Lovgren-2
    replied
    Thanks Dave. Binary does work better with Unicodes, The $CrLf's were showing up in the text output but don't with Binary and act "normal" lf's. Here's the latest code and picture of the output in BabelPad (which is turning out to feature rich, way more than I want or need right now)
    Attached Files
    Gösta H. Lovgren-2
    Member
    Last edited by Gösta H. Lovgren-2; 22 May 2009, 03:57 PM.

    Leave a comment:

  • Dave Biggs
    Member

  • Dave Biggs
    replied
    See how you go wth this Gösta
    Code:
    '
    ' *******************************************************
    '    
    Macro pf = Put$ #fn, 
    '
    Macro Uni_Save
      Local fn As Long
      Local fl, Ulf As String
      fn = FreeFile
      fl$ = CurDir$ & "\Uni_Test.txt"
      Open fl$ For Binary As #fn
      SEEK #fn, LOF(#fn) + 1
    '
      Ulf$ = UCode$($Cr) 'line feed
      pf UCode$(Date$ & " " & Time$) & Ulf$  'so as to differentiate between runs
      For ctr = LBound(Id_Uni_Codes()) To UBound(Id_Uni_Codes())
          Pf  ControlGetTextUnicode(CB.Hndl, Id_Uni_Codes(ctr)) 
          pf  Ulf$  'line feed needed as simple pf just doesn't work like it does in ASCII
      Next ctr
      Close fn 
    End Macro
    '
    ' *******************************************************
    '

    Leave a comment:

  • Gösta H. Lovgren-2
    Member

  • Gösta H. Lovgren-2
    replied
    Been playing around a little more and trying to write to a Uni Text file but I can't find a $CrLf (line feed) that doesn't print a unicharacter. (looks like a square U - see attached). I searched for a uni linefeed but only found technical discussions.
    Code:
    '
    ' *******************************************************
    '    
    Macro pf = Print #fn, 
    '
    Macro Uni_Save
      Local fn As Long
      Local fl, Ulf As String
      fn = FreeFile
      fl$ = CurDir$ & "\Uni_Test.txt"
      Open fl$ For Output As #fn
    '
      Ulf$ = UCode$($Cr) 'line feed
      pf UCode$(Date$ & " " & Time$) & Ulf$  'so as to differentiate between runs
      For ctr = LBound(Id_Uni_Codes()) To UBound(Id_Uni_Codes())
          Pf  ControlGetTextUnicode(CB.Hndl, Id_Uni_Codes(ctr)) 
          pf  Ulf$  'line feed needed as simple pf just doesn't work like it does in ASCII
      Next ctr
      Close fn 
    End Macro
    '
    ' *******************************************************
    '
    I tried a whole host of variations for Ulf$ but they all show up the uni editor (BabelPad). (Does anyone have a better suggestion for a uni editor? BabelPad is okay but I'd like to see the code in hex too (like UltraEdit)

    Any ideas, anyone? Anything?

    ==============================
    Men and nations behave wisely
    once they have exhausted
    all the other alternatives.
    Abba Eban (1915-2002)
    ==============================
    Attached Files

    Leave a comment:

  • Michael Mattias
    Member

  • Michael Mattias
    replied
    And if the font does not exist....the charcters displayed are certainly not 48 pt,
    DIALOG FONT
    ...
    If the requested font is not available on the computer, Windows will search for a substitute font, which is as similar as possible
    Sounds like Windows (with apologies to Sir Lawrence Olivier), "chose poorly."

    Leave a comment:

  • Gösta H. Lovgren-2
    Member

  • Gösta H. Lovgren-2
    replied
    Actually we may have been both right, Walter. If, as you say, the character set is not correctly set in the OS unicodes won't display. And if the font does not exist, the characters displayed will be very small. I just tried it with
    Code:
      Dialog Font "NO_Font_exists", 48 '48 fits 8 Japanese chars on 800 wd screen nicely
    and the charcters displayed are certainly not 48 pt, as Colin's jpg shows.

    ==========================
    "We didn't lose the game;
    we just ran out of time."
    Vince Lombardi
    ==========================
    Gösta H. Lovgren-2
    Member
    Last edited by Gösta H. Lovgren-2; 20 May 2009, 09:35 PM.

    Leave a comment:

  • Gösta H. Lovgren-2
    Member

  • Gösta H. Lovgren-2
    replied
    Yours is the more likely reason, Walter. We posted together and I had not seen your explanation before I posted.

    ================================
    "It is a miracle that curiosity
    survives formal education."
    Albert Einstein (1879-1955)
    ================================

    Leave a comment:

  • Gösta H. Lovgren-2
    Member

  • Gösta H. Lovgren-2
    replied
    The program uses the Consolas font (48 ppt). My bet is that it's not installed on your computer.Change the
    Code:
      Dialog Font "Consolas", 48 '48 fits 8 Japanese chars on 800 wd screen nicely
    in PBMain to another font and recompile.

    See the attached jpeg to see how it looks on my machine (and presumably any that have Consales installed).

    I uploaded the .exe with Courier 48 as the font: http://www.SwedesDock.com/powerbasic...es_Example.exe

    ================================================
    "Not everything that can be counted counts,
    and not everything that counts can be counted."
    Albert Einstein (1879-1955)
    ================================================
    Attached Files

    Leave a comment:

  • Walt Thompson
    Member

  • Walt Thompson
    replied
    Hi Colin;

    A possible cause of the problem you experienced is your computer is set up for Windows: Western Character Set instead of Unicode. Launch charmap.exe
    ans verify that Character Set is set to Unicode.

    Leave a comment:

  • colin glenn
    Member

  • colin glenn
    replied
    Originally posted by Gösta H. Lovgren-2 View Post
    What's not working?

    Hard to tell (Problem not shown).
    Haven't tried compiling the example, but running the example program gives me this:
    .
    Attached Files

    Leave a comment:

  • Gösta H. Lovgren-2
    Member

  • Gösta H. Lovgren-2
    replied
    Originally posted by colin glenn View Post
    This isn't working for me,
    What's not working?
    what am I missing?
    Hard to tell (Problem not shown).

    ======================================
    "The man who does not read good books
    has no advantage
    over the man who cannot read them."
    Mark Twain (1835-1910)
    ======================================

    Leave a comment:

  • colin glenn
    Member

  • colin glenn
    replied
    This isn't working for me, what am I missing?

    Leave a comment:

  • Gösta H. Lovgren-2
    Member

  • Gösta H. Lovgren-2
    replied
    Ne hao mes amigos et mon amis, the latest code has been uploaded and the exe is here: http://www.SwedesDock.com/powerbasic...es_Example.exe

    Solong salinga.

    =================================
    "Too many pieces of music finish
    too long after the end."
    Igor Stravinsky (1882-1971)
    =================================
    Attached Files

    Leave a comment:

  • Dave Biggs
    Member

  • Dave Biggs
    replied
    Hi Gösta
    Just no saw it and gave it a quick look. Not sure what it's supposed to do yet.
    Not so much really. I'd been playing around with Kev's code (to rewrite it without that scary ASM) so had an example that used more than one static control.

    I also wanted to see if I could put the ControlGetTextUnicode() function to use.

    Last year I was involved in a project that required chinese character input into a non PB application. It was to display editable passenger messages on the TV systems of a couple of ferry boats that were being prepared for delivery to Hong Kong.
    (Had to learn about the 'Microsoft Pinyin Input Method' in the process.. http://newton.uor.edu/Departments&Pr...nese_write.htm ).

    At the time I didn't think it would be possible to use PB as part of the solution due to it's native ANSI controls, now I think it might have been doable after all!

    Leave a comment:

  • Gösta H. Lovgren-2
    Member

  • Gösta H. Lovgren-2
    replied
    Originally posted by Dave Biggs View Post
    Your new control is now visible
    But I think you need some changes to 'Macro Update_Controls' also? -
    Yes, I know but I just came up on the visibility thing and hadn't gotten to the screen update yet. I just posted the "explanatory" section in case any were puzzled or had a reason why the different controls needed to be sized differently. I uspect it has to do with the way Dialof Font is handled.
    We posted around the same time earlier - did you see post #16 ?
    Just no saw it and gave it a quick look. Not sure what it's supposed to do yet.

    I'll (re)upload my complete code as soon as I get the screen worked out. Will display 8 rows of 8 uni chars in big type (48 pt). (I'm fascinated with the kanji chars - around chr$(20000).)

    =====================================
    "If all who have eyes to see
    are silenced,
    then the rest will live in a kingdom
    of blind
    for a very long time."
    Elena Filatova (1975 -)
    =====================================

    Leave a comment:

  • Dave Biggs
    Member

  • Dave Biggs
    replied
    Your new control is now visible
    But I think you need some changes to 'Macro Update_Controls' also? - can't just plug your changes into the previously posted code.

    We posted around the same time earlier - did you see post #16 ?

    Leave a comment:

  • Gösta H. Lovgren-2
    Member

  • Gösta H. Lovgren-2
    replied
    Originally posted by Gösta H. Lovgren-2 View Post
    (Quoting himself. Lord, he really loves to do that.)
    ...
    I was trying to add multiple lines but can't seen to create more Unicode controls:
    ...

    %Id_Uni_Control_02 does not get created. Is there a limit of only one uni control, Kev? Or (as is most likely I'm doing something wrong?) Is there a limit of only 1 STATIC class per dialog or something?
    Okay, a night's sleep (Ambien assisted), a hot shower (112F), and I got the answer.

    The height of the Unicode controls are measured differently than "regular" controls. See bolds in code.

    Row = 0 so establish uni control at very top of dialog.. By trial and error, I determined for the test label to show ompletely it had to be established at Row 80 otherwise it would be (partially) overwritten by the first uni control.

    So I was trying establish the second uni control at Row 80 (3rd at 160, etc.) but it turns out that was WAY too far down. The next uni control Row had to be at Row 6, not 80 (see Uni_Spacer in code).

    Now why there would be a huge difference between the way "regular" controls are placed and the way unis are placed eludes me for the moment. (and probably forever, most likely).

    Code:
     ...
      Dialog Font "Consolas", 48 '48 fits 8 Japanese chars on 800 wd screen nicely
    ...
      'bytes to start
      LSB = 65
      MSB = 91 '0
     
      wd = dlg_wd - 20
      ht = 10
    [B] Row = 0[/B]
      col = 0
     
     [B] char_ht = 80 [/B]  
      [B]Uni_Spacer = 6[/B]
          'test for char ht 
       Control Add Label, hdlg, -1, "CHR test" & String$ (10,"X"), col, [B]Row + char_ht[/B], 600, char_ht, %ss_left
     
      ' Create a unicode child window (uses A face for text)...
      ControlAddUnicode UCode$("STATIC"), hDlg, %Id_Uni_Control_01, Chr$(LSB, MSB), Col, [B]Row[/B], wd, ht
     
      [B]Row = Uni_Spacer[/B] 'Char_Ht + 10 'next row 
       ControlAddUnicode UCode$("STATIC"), hDlg, %Id_Uni_Control_02, Chr$(LSB, MSB), Col, Row, wd, ht
    ================================================
    "My occupation now, I suppose, is jail inmate."
    Unibomber Theodore Kaczynski
    when asked in court what his
    current profession was
    ================================================

    Leave a comment:

Working...
X