Arabic Numbers display on one machine but not another
Hello everybody, I am using this function to convert the standard numbers
0123456789 to arabic numbers ٠١٢٣٤٥٦٧٨٩
It is working on one machine it does the conversion but not on another where it returns the standard 0123456789 digits. Both machines are displaying the arabic text correctly in the application, the only difference is with the numbers. Anybody have any ideas?
Code:
Public Function ConArNum(ByVal strStringToConvert As String) As String
On Error GoTo ErrorHandler
strStringToConvert = Replace$(strStringToConvert, "0", ChrW$(1632))
strStringToConvert = Replace$(strStringToConvert, "1", ChrW$(1633))
strStringToConvert = Replace$(strStringToConvert, "2", ChrW$(1634))
strStringToConvert = Replace$(strStringToConvert, "3", ChrW$(1635))
strStringToConvert = Replace$(strStringToConvert, "4", ChrW$(1636))
strStringToConvert = Replace$(strStringToConvert, "5", ChrW$(1637))
strStringToConvert = Replace$(strStringToConvert, "6", ChrW$(1638))
strStringToConvert = Replace$(strStringToConvert, "7", ChrW$(1639))
strStringToConvert = Replace$(strStringToConvert, "8", ChrW$(1640))
strStringToConvert = Replace$(strStringToConvert, "9", ChrW$(1641))
ConArNum = strStringToConvert
Exit Function
ErrorHandler:
ConArNum = vbNullString
End Function
Re: Arabic Numbers display on one machine but not another
check the font in use....
-tg
Re: Arabic Numbers display on one machine but not another
Quote:
Originally Posted by
techgnome
check the font in use....
-tg
Thanks for your reply, both use the same font (which is Tahoma), in any case I change the charset, and make sure the font works with that charset.
Keep in mind all arabic text is showing correctly on both machines, the problem is only with the digits.
Re: Arabic Numbers display on one machine but not another
Are the Regional settings the same?
Re: Arabic Numbers display on one machine but not another
Quote:
Originally Posted by
MartinLiss
Are the Regional settings the same?
Thanks for your reply. Yes regional settings are the same. English is the main language, and Arabic is the language for non-unicode programs. All script is working perfectly except the digits.
I even tried loading from a unicode text file, arabic text mixed with arabic numbers and the text gets displayed the numbers change to 0123456789.
I am thinking it has something to do with the codepage used? If so is there a way of having the application use the same codepage all the time independent of the machine? (Of course the regional settings must be set for arabic).
Re: Arabic Numbers display on one machine but not another
What do you use to convert the non-numeric characters?
Re: Arabic Numbers display on one machine but not another
Quote:
Originally Posted by
MartinLiss
What do you use to convert the non-numeric characters?
I don't do anything, I just set the charset of the control (in this case 178), select a font that is compatible with that charset. The charcters are stored as unicode charcters.
One thing that I noticed, I looked at the codepage of 1256 (which is arabic) here:
http://msdn.microsoft.com/en-ca/goglobal/cc305149.aspx
And I noticed that the digits are european digits. So maybe there is a different codepage being used on that machine that displays the arabic digits?
Re: Arabic Numbers display on one machine but not another
Curiosity. Are both machines WinXP and above? Or is one Win2K and below?
Re: Arabic Numbers display on one machine but not another
Quote:
Originally Posted by
LaVolpe
Curiosity. Are both machines WinXP and above? Or is one Win2K and below?
I made a mistake in my statement that it works on one machine but not on the other. It doesn't work on either machine. I was testing the code on one machine using VB6, and testing the code on another machine with access vba (which I had assumed would return the same results as VB6). It doesn't work on either machine with VB6, it works on both machines with access VBA.
So my question then becomes, how can I make this work with VB6? Any assistance would be appreciated.
(I am looking now into api calls like MultiByteToWideChar that may present a solution.)
Re: Arabic Numbers display on one machine but not another
Let me ask again about the language setting and ask which one is being used? I don't see an Arabic choice.
Re: Arabic Numbers display on one machine but not another
Quote:
Originally Posted by
MartinLiss
Let me ask again about the language setting and ask which one is being used? I don't see an Arabic choice.
1. In the Languages tab I have "Install files for complex script and right-to-left languages" checked
2. In Advanced tab I have "Langauge for non-unicode programs" on Arabic
This permits me to see all characters in correct arabic script except the numbers which remain standard.
Thanks again for any input.
Re: Arabic Numbers display on one machine but not another
I tried putting the bytes in directly for example the arabic digit 4 is
Code:
bytArabic4(0) = 100
bytArabic4(1) = 6
and then calling MultiByteToWideChar but I still get the same result instead of displaying ٠١٢٣٤٥٦٧٨٩ it is displaying 0123456789. I have tried using
again with the digit being displayed as 4. Like I mentionned before I am correctly displaying text. The problem is with digits.
Here is the MultiByteToWideChar code
Code:
'ANSI to UNICODE conversion, via a given codepage.
Public Function AToW(ByVal strArNumeral As String, ByVal lngCodePage As Long) As String
Dim strBuffer As String
Dim lngLength As Long
Dim lngPointerToString As Long
Dim lngPointerToBuffer As Long
Dim lngFlags As Long
On Error GoTo ErrorHandler
lngFlags = 0
lngPointerToString = StrPtr(strArNumeral)
lngLength = MultiByteToWideChar(lngCodePage, lngFlags, lngPointerToString, -1, 0&, 0&)
strBuffer = String$(lngLength + 1, vbNullChar)
lngPointerToBuffer = StrPtr(strBuffer)
lngLength = MultiByteToWideChar(lngCodePage, lngFlags, lngPointerToString, -1, lngPointerToBuffer, Len(strBuffer))
AToW = StrConv(Left$(strBuffer, lngLength - 1), vbFromUnicode)
Exit Function
ErrorHandler:
AToW = strArNumeral
End Function
Re: Arabic Numbers display on one machine but not another
This probably won't help but it's worth a shot.
Re: Arabic Numbers display on one machine but not another
Quote:
Originally Posted by
MartinLiss
This probably won't help but it's worth a shot.
Thanks, but you were right it didn't change much. I am starting to run out of ideas. It is strange that all characters except digits can be displayed in arabic.
Re: Arabic Numbers display on one machine but not another
Have you ever been able to display an arabic number in any program?
Re: Arabic Numbers display on one machine but not another
Maybe you don't have a problem. See the second comment at this site and what's said about columns 2 and 6 here. (on my display column 6 isn't actually broken out from column 5).
(Sorry for so many posts but I just find this problem interesting.)
Re: Arabic Numbers display on one machine but not another
Quote:
Originally Posted by
MartinLiss
Have you ever been able to display an arabic number in any program?
Hello MartinLiss, thanks for your comments. Yes, if in Regional and Language Options control panel, if you select Arabic in Standards and Formats, all the dates, currencies, numbers etc... appear in standard VBfunctions.
i.e. If I call the Date function and put the contents in a Label caption it will be displayed in Arabic in the VB program including the numbers.
But I don't want the user to be forced to do that, it should be enough that they install complex script and select arabic for non-unicode programs.
In any case I didn't test yet if I did that would the numbers that appear in my ressource file or text file appear correctly. I will test that tonight and let you know. However I hope that would not be the only way as the program runs on English computers and forcing people to change their standards and formats wouldn't be acceptable for users.
Re: Arabic Numbers display on one machine but not another
Quote:
Originally Posted by
Hassan Basri
Hello MartinLiss, thanks for your comments. Yes, if in Regional and Language Options control panel, if you select Arabic in Standards and Formats, all the dates, currencies, numbers etc... appear in standard VBfunctions.
i.e. If I call the Date function and put the contents in a Label caption it will be displayed in Arabic in the VB program including the numbers.
But I don't want the user to be forced to do that, it should be enough that they install complex script and select arabic for non-unicode programs.
In any case I didn't test yet if I did that would the numbers that appear in my ressource file or text file appear correctly. I will test that tonight and let you know. However I hope that would not be the only way as the program runs on English computers and forcing people to change their standards and formats wouldn't be acceptable for users.
I'm sorry but I don't understand what you're saying.
Re: Arabic Numbers display on one machine but not another
Quote:
Originally Posted by
MartinLiss
I'm sorry but I don't understand what you're saying.
Sorry if I wasn't clear, what I mean is that if I go to Regional and Language options in the control panel. In the first tab (under XP) there is a section "Standards and Formats". If I select one of the Arabic formats, then all the return values of standard vb functions like date, time, SmallDate etc... follow the arabic format which includes numbers.
So If I call the Date function in VB with the above set, and put the result into a Labal I would see the arabic numbers.
Re: Arabic Numbers display on one machine but not another
2 Attachment(s)
Re: Arabic Numbers display on one machine but not another
To view Arabic numbers (٠ - ١- ٢ - ٣ - ٤ - ٥ - ٦ - ٧ - ٨ - ٩) correctly use this font:
Which attached with this post.
These two fonts will force Arabic numbers display in any part of your application.
This way also will work fine with Crystal Reports.
Some people called them Hindi numbers, but it's wrong, Indian Numerals are different, and Indian Numerals is the origin of western numbers (Arabic numerals).
The source of the following image is from Wikipedia.
Re: Arabic Numbers display on one machine but not another
If you do the following you see Arabic numbers for all application.
Control Panel -> Regional and Language Settings
Under Regional Options
Choose an Arabic Locale for Standards and Formats.
Then click Customize.
At the bottom of the options change "Digit Substitution" to "National".