Results 1 to 6 of 6

Thread: Kanji? (Chinese windows)

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2000
    Posts
    14
    I've got a program that runs fine on 'English' versions of windows, but I have problems when it's run on the Chinese Version...

    (Using VB6 btw)

    I save some text (usually copied to the clipboard) to a file using...
    Code:
    Public Sub addclip(Index As Integer, text As String)
    Dim outfile As Integer
    outfile = FreeFile
    Open path + "\Clip" + Str(Index) + ".txt" For Append As outfile
    Print #outfile, text
    Close outfile
    End Sub
    Reading back the same file sometime later...
    Code:
    Public Function readclip(Index As Integer) As String
    Dim inFile%, clip$
    On Error GoTo readcliperror
    inFile = FreeFile
    Open path + "\Clip" + Str(Index) + ".txt" For Input As inFile
    clip = Input(LOF(inFile), #inFile)
    Close inFile
    readclip = clip
    Exit Function
    readcliperror:
    If Err = 53 Then 'file not found
        readclip = "no more clips:" + Chr(9)
        Exit Function
    End If
    If Err = 76 Then 'path not found
        readclip = "no more clips:" + Chr(9)
        MkDir App.path + "\clips"
        Exit Function
    End If
    End Function
    ... comes back with error 62 (Input past end of file).

    The only difference that's apparent between the English and Chinese versions of windows is that the Chinese is using Kanji.

    Is there anything I can do to solve this? I can't get hold of Chinese Windows (this is an unpaid project so I can't really afford to buy it), and searches on VB Help, Google and on here haven't turned up anything.

    I don't feel catching err 62 like I have with 53 and 76 is a viable solution (unless someone can come up with a good reason why it is).


    Anyone?
    Shab.

    Code:
    Print WeekDayName(vbMonday)

  2. #2
    PowerPoster BruceG's Avatar
    Join Date
    May 2000
    Location
    New Jersey (USA)
    Posts
    2,657
    I have gotten the input past EOF error when I do the Input function to load a file into a multi-line text box. I was able to solve this by opening the file For Binary as opposed to For Input. I don't know why this works, but it does. I don't know about Chinese Windows or Kanji, but you might try the Open For Binary and see if the error goes away. Good luck.
    "It's cold gin time again ..."

    Check out my website here.

  3. #3

    Thread Starter
    New Member
    Join Date
    May 2000
    Posts
    14
    Originally posted by BruceG
    I don't know about Chinese Windows or Kanji, but you might try the Open For Binary and see if the error goes away. Good luck.
    Cheers Bruce - I'll give this a go - I won't find out for a week or so - I've other mods to do before I release this version.

    Shab.

    Code:
    Print WeekDayName(vbMonday)

  4. #4
    Fanatic Member
    Join Date
    Feb 2000
    Location
    Japan
    Posts
    840

    Cool

    I can help you here.

    What you're seeing is an effect of DBCS (Double byte Character systems) not all vb functions support this properly. (eg, len and lenB return different values for the same text when in DBCS format.

    There's no information on how the lof function is reading the file, so try the filelen() function instead and see if it works better.

    probably what is happening with read past EOF is this:

    lof returns (eg) 1000 bytes of size
    this is only 500 DBCS characters
    if you read till 1000 you'll get the above error at char 501!

    just as an experiment try dividing the Lof by 2 before you read! ( It looks like the lof returns byte and the input reads in characters)

    Let me know how you go. Most of my time is spent using English VB on Japanese (Kanji) system

    Paul Dwyer
    Network Engineer
    Aussie In Tokyo

    Using Powerbasic 6 & VB6 SP4 (Please also add your VB Version to your signature!)

  5. #5
    Hyperactive Member
    Join Date
    Jun 1999
    Location
    Taipei
    Posts
    318

    Cool

    I usually will not use the input function to read files with Chinese characters inside since the second byte sometimes contain control character. I usually use Line Input and it never come out problem.

    I agree with Paul that Len, LenB, Mid, MidB is very difficult to use. My experience is M$ is sh**, they expect you either have all DBCS inside a string or all single byte inside a string. If you mix DBCS and single byte inside a string, then those function always return very strange result. As a result in Taiwan, local people rewritten all these functions to examine every byte by byte.


  6. #6
    Fanatic Member
    Join Date
    Feb 2000
    Location
    Japan
    Posts
    840
    true

    Where I have to use normal and DBCS text in the same doc I try to delimit it, cut it with the split function, then work on entirely DBCS or non DBCS text.

    There are some functions for determining whether a byte is non DBCS or high byte or low byte section of DBCS, but they're a hassle and I can't be bothered writeing functions to check everything (although I should build a few classes I suppose)

    Here's a task that got me: Try to build a text colour function that works for changing html tags when some of the text is DBCS! you're find positions go out the window and you need to capture with instr() and you colour the wrong areas.

    Paul Dwyer
    Network Engineer
    Aussie In Tokyo

    Using Powerbasic 6 & VB6 SP4 (Please also add your VB Version to your signature!)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width