Android Question Hebrew Currency with Number String

EvgenyB4A

Active Member
Licensed User
Longtime User
I need to output the string like שח 10.00 where שח will be at the start and then 10.00. I can't succeed in anyway.
 

emexes

Expert
Licensed User
B4X:
Dim IOU As Double = 10.15    'money values better as Double (Float is only 6 digits accurate)
Dim MoneyString As String = "שח " & NumberFormat2(IOU, 1, 2, 2, False)
Log("How about " & MoneyString & " ?")

IOU = IOU * 2
MoneyString = Chr(8362) & " " & NumberFormat2(IOU, 1, 2, 2, False)
Log("Or do you prefer " & MoneyString & " ??")
 
Last edited:
Upvote 0

EvgenyB4A

Active Member
Licensed User
Longtime User
Anyway I get the following: "How about שח 10.15 ?" I need that שח will be the first and then 10.15
 
Upvote 0

emexes

Expert
Licensed User
Yeah, I just tested the second sample Chr(8362) and noticed that the first sample was still the wrong way around. That's interesting. I remember with Arabic writing in Windows, text used to move itself about when changing direction, perhaps the same is happening here when the text output routine sees your currency symbol.

update: the B4A IDE cursor does very strange things when traversing those characters too...
 
Upvote 0

EvgenyB4A

Active Member
Licensed User
Longtime User
It is not because of currency symbol. If English part of string will be like "abcd" al will loos OK : " שח abcd" .
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
B4X:
Dim IOU As Double = 10.15   
    Dim s As String=NumberFormat2(IOU, 1, 2, 2, False)
    Log($"nw ${s}"$)    'displays: nw 10.15
 
Upvote 0

emexes

Expert
Licensed User
I am going to have to admit defeat on this one, for tonight at least.

If you place text between the currency characters, then they stay in left-to-right order. So I figure if I could just find some non-printing characters to put between the currency characters, that would do the job (although no doubt I'd cop an ear-bashing from Erel ;-)

However, that doesn't work. Java's handling of text direction is irritatingly thorough.

I tried CSBuilder too, thinking that the formatting codes in that might interrupt the text direction handling, but... no luck there either.
 
Upvote 0

emexes

Expert
Licensed User
Or apparently CSBuilder can include images within a string, so... you could include an IMAGE of the two currency characters... bit of an icky solution, but hey: if it works, it works ;-)
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
Or apparently CSBuilder can include images within a string, so... you could include an IMAGE of the two currency characters... bit of an icky solution, but hey: if it works, it works ;-)
Use string literals, you will get it:
B4X:
Dim IOU As Double = 10.15  
    Log($"nw ${NumberFormat2(IOU, 1, 2, 2, False)}"$)  'displays: nw 10.15
 
Upvote 0

emexes

Expert
Licensed User
Give this a burl:
B4X:
Dim IOU As Double = 10.15    'money values better as Double (Float is only 6 digits accurate)
Dim MoneyString As String = Chr(0x200F) & NumberFormat2(IOU, 1, 2, 2, False) & " " & Chr(1513) & Chr(1495)
Log("How about " & MoneyString & " ?")

IOU = IOU * 2
MoneyString = Chr(8362) & " " & NumberFormat2(IOU, 1, 2, 2, False)
Log("Or do you prefer " & MoneyString & " ??")
 
Last edited:
Upvote 0

emexes

Expert
Licensed User
It works. Chr(0x200F) makes a job.
I wish I could explain why it works, except that I'm a bit hazy about it myself.

Likewise, I wish I could say that I derived the solution by skill and wisdom, but in fact it was more by perseverance and luck.

I googled Unicode left right direction and eventually I found pages like http://unicode.org/reports/tr9/#Explicit_Directional_Embeddings

and from there I tried using various directional formatting characters and sequences until I found one that worked with both Log() and with Label.Text =
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…