Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 142
  • Last Modified:

VB and Languages

Hi,

I am creating an application which reads and writes hebrew text to a .txt file, and displays the text in a listbox.
I guess that somewhere along the process of reading/writing something goes wrong and the text turns to ...strange unreadable characters.
can someone help me out, maybe some example source on how to get this done correctly?

all i need is to write hebrew text to a file,  and read it back in.
I tried of course to set the font of the listbox and other controls on the form to a hebrew font, but that doesnt seem to help ( so i suppose its in the writing process of the file which things go wrong?)

thanks in advance!
0
11ods
Asked:
11ods
1 Solution
 
stretch71Commented:
There are many reasons why this could be happening.  The problem is that while VB works in unicode internally, all it's interfaces work in ANSI code pages.

What often happens is that VB will do the ANSI to Unicode conversion automatically and that this process can cause your data to be screwed up.

Without knowing more, I am assuming that the text file is created in another application (such as wordpad) and that you are reading the file in, updating it and then writing it back out.

If the application that created the initial text file saves it as unicode then VB will make a mess of it, since it will assume that the unicode string is actually an ANSI string.  To get around this, you need to read the data into a byte array and convert it to a string using a straight assignment operator.

If you could supply more info about what you are doing, and the OS involved I can help you further.
0
 
VBtomCommented:
Hi 11ods

You need to find a font that can display a hebrew font in it's basic 0..255 charset, because text in VB controls is ANSI. Set this as the font of the listbox.
Only that should do it.
Should be easy to find with google (I needed before polish and greek fonts for similar reasons, it's easy to find free fonts on the net).

You're very lucky it's a text file (ANSI also) and not a unicode source, cause in the case of unicode, the charcters would be converted using the default codepage and the solution would be much more complex!
0
 
11odsAuthor Commented:
thanks both of you,

I intalled the application on the clients computer which is a hebrew based windows-unlike mine- and the application seemed to work great. read hebrew, wrote hebrew... etc.

thanks !
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now