VB and Languages

Posted on 2003-03-30
Medium Priority
Last Modified: 2010-05-01

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!
Question by:11ods
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Expert Comment

ID: 8235270
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.

Accepted Solution

VBtom earned 600 total points
ID: 8240858
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!

Author Comment

ID: 8249270
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 !

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month12 days, 6 hours left to enroll

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question