Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

read unicode file and display it

Status
Not open for further replies.

ElvisUntot

Programmer
Jan 8, 2002
72
DE
can anyone tell me how to read an unicode file and how to display it?

 
you can just use the open yourfile for input as #1 to read it in (vb converts it for you)

give this a try to show the point
Code:
Private Sub Command1_Click()
    
    mystring = "hello world"
    
    mystring = StrConv(mystring, vbUnicode)
    debug.print mystring
    
    Open "c:\tempunicode.txt" For Output As #1
    Print #1, mystring
    Close #1
    
    'check the file you will see it is in unicode format

    mystring = ""
    
    Open "c:\tempunicode.txt" For Input As #1
    Input #1, mystring
    Close #1
    debug.print mystring
    
End Sub

good luck!!

If somethings hard to do, its not worth doing - Homer Simpson
------------------------------------------------------------------------
A General Guide To Excel in VB FAQ222-3383
File Formats Galore @
 
if i read out a textfile i made with the editor

dies ist ein test: "阿野 バカ です"

with the programm i get

þÿdies ist ein test: "–?‘Î00Ð0«00g0Y"


(dont know if this is displayed correctly for you)
(and the file is recognized as a unicode file by other programs)
 
hmmm.... erm.... ok open the file as binary access read:-

open file for binary access read as #freefile

then read the bytes into a byte array

use the yourstring=strconv(yourbytearray,vbFromUnicode)

then assuming the charater set is supported in your version of VB the chaaracters should be there!

ive never used any character sets other than western styles so i cant offer you any more help on the subject!!

good luck!

If somethings hard to do, its not worth doing - Homer Simpson
------------------------------------------------------------------------
A General Guide To Excel in VB FAQ222-3383
File Formats Galore @
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top