Announcement

Collapse
No announcement yet.

Open/read Unicode file contents and display

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Bert Slootmans
    replied
    Originally posted by Dave Biggs View Post
    Bert,

    Have a look at the sample I posted in that thread (#16) http://www.powerbasic.com/support/pb...0&postcount=16

    That shows a couple of ways to set the font in the Unicode controls created with a variation on Kev's method.
    YES!!! It works!! Thanks ALL :smiling:

    Leave a comment:


  • Dave Biggs
    replied
    Bert,

    Have a look at the sample I posted in that thread (#16) http://www.powerbasic.com/support/pb...0&postcount=16

    That shows a couple of ways to set the font in the Unicode controls created with a variation on Kev's method.

    Leave a comment:


  • Michael Mattias
    replied
    In the example I gave you the link to, there is an example of changing the font.

    Try creating your font with CreateFont as shown in demo instead of FONT NEW and see what happens.

    Leave a comment:


  • Bert Slootmans
    replied
    Originally posted by Michael Mattias
    It might be better us open the file for BINARY access and handle the parsing a little differently.
    Took me a while to figure out how to parse the string but this works fine now.

    Also the code referenced in the next quote works perfect.

    Originally posted by Dave Biggs
    See this thread for more info on creating Unicode controls in PB..
    http://www.powerbasic.com/support/pb...ad.php?t=40544
    All I need to know now is how I can change the font of this Unicode control.

    I've tried this:
    Code:
      IF hCtl THEN
         ' Either use parent font or Windows' GUI font...
         LOCAL hFont AS DWORD
         hFont = SendMessage(hParent, %WM_GETFONT, 0, 0)
    '     IF (hFont = %NULL) THEN hFont = GetStockObject(%DEFAULT_GUI_FONT) ' Original code, changed with next line:
         FONT NEW "Arial Unicode MS", 288, 0 TO hfont
         SendMessage hCtl, %WM_SETFONT, hFont, %TRUE
         FUNCTION = hCtl
      END IF
    But that doesn't do much (only changes the font to BOLD).

    Any idea?

    Leave a comment:


  • Michael Mattias
    replied
    Just FYI...
    Code:
    OPEN "data\Chinese.dat" FOR INPUT AS 1
       WHILE ISFALSE EOF(1)  ' check if at end of file
          LINE INPUT #1, strtempchar
    Using the LINE INPUT# or PARSE statements, or any of the functions designed for use with "text" pretty much assumes that text is "regular ASCII" and you "may" have some problems with Unicode.

    Eg, LINE INPUT # is documented to read from the current file position up the next CRLF or end of file; but CRLF is NOT CHR$(13,10) in a Unicode file. (In Real Life LINE INPUT does not work this way, it never has; but maybe someday the behavior will match the documentation). (It actually reads up to CR, not CRLF).

    It might be better us open the file for BINARY access and handle the parsing a little differently.

    MCM

    Leave a comment:


  • Dave Biggs
    replied
    RichEdit control used as a label can display Unicode (Chinese etc) characters.
    They can be made to look like a label easily enough..
    http://www.powerbasic.com/support/pb...ad.php?t=22402

    See this thread for more info on creating Unicode controls in PB..
    http://www.powerbasic.com/support/pb...ad.php?t=40544

    Leave a comment:


  • Michael Mattias
    replied
    DDT does not support Unicode. You'll have to use SDK-style coding. Here's a demo to get you started:Directory List with Non-ASCII (Unicode) characters in file names 5-31-08

    (There are some other demos of this, as this subject has come up numerous times).

    If you only have one or two controls which must support unicode on the screen, you might (that means I've never tried it) be able to use DDT syntax to create the controls, but you'll have to owner-draw them ... which owner-drawing will require SDK-style commands.

    FWIW, a regular edit (class "edit") control offers the style ES_READONLY, but if you are creating Unicode controls anyway you may as well stick with the label ("static") control.

    Leave a comment:


  • Edwin Knoppert
    replied
    A disabled richedit does not seem to appear with gray colors.

    Leave a comment:


  • Bert Slootmans
    started a topic Open/read Unicode file contents and display

    Open/read Unicode file contents and display

    I need to be able to open a text file with Unicode content (Chinese characters and Pinyin).

    Using the following code I am able to read the first Chinese character correctly, but NOT the following Pinyin. The next character is read, but is again incorrect. Only plain Asci characters are loaded corectly.

    Code:
    SUB LoadCharacters ()
       DIM strTempChar AS STRING
       DIM strTemp AS STRING
       DIM strTempMeaning AS STRING
       OPEN "data\Chinese.dat" FOR INPUT AS 1
       WHILE ISFALSE EOF(1)  ' check if at end of file
          LINE INPUT #1, strtempchar
          strtemp = PARSE$(strtempchar,1)
          UniMsgBox BYVAL 0, STRPTR(strtemp), 1, BYVAL 0
          strtempmeaning = fixtextline(PARSE$(strtempchar,2))
     
          MSGBOX strtempmeaning
     
          intcounter = intcounter + 1
          REDIM PRESERVE strCharacter(intcounter)
          REDIM PRESERVE strMeaning(intcounter)
          strCharacter(intcounter) = strtempchar
          strMeaning(intcounter) = strtempmeaning
     
       WEND
       CLOSE 1
    END SUB
    How can I fix this? and how can I display this Unicode on a PBWin label control (I don't want to use the richtextbox because everything needs to stay read-only)?
Working...
X