Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / April 2007

Tip: Looking for answers? Try searching our database.

can you help me in java

Thread view: 
الصباغ - 11 Apr 2007 07:01 GMT
while i searching about my problem i found this group and i hope to
find solution for this problem, so let me tell you about my problem:

i want to show and print the numbers in arabic forms not in english,
called indian or farisy numbers,i can show the arabic words,so how can
i convert or replase english numbers to arabic?

thank you.
Andrew Thompson - 11 Apr 2007 11:17 GMT
> while i searching about my problem i found this group ..

Which group?  This was posted to three groups
separately, which is usually called a multi-post.

Please refrain from multi-posting, in future.
<http://www.physci.org/codes/javafaq.html#xpost>

(X-post to c.l.j.p./g./h., w/ f-u to c.l.j.p. only)

Andrew T.
Lew - 11 Apr 2007 13:43 GMT
"الصباغ" <sabd1...@yahoo.com> wrote:
>> while i searching about my problem i found this group ..

> Which group?  This was posted to three groups
> separately, which is usually called a multi-post.
[quoted text clipped - 3 lines]
>
> (X-post to c.l.j.p./g./h., w/ f-u to c.l.j.p. only)

sabd1 said:
> i want to show and print the numbers in arabic forms not in english,
> called indian or farisy numbers,i can show the arabic words,so how can
> i convert or replase english numbers to arabic?

This is a very popular homework assignment.  Was this homework?

> i [sic] hope to find solution for this problem,

Post the solution you've already tried and tell us what /specific/ difficulty
you're having.

Signature

Lew

Andrew Thompson - 11 Apr 2007 14:33 GMT
>sabd1 said:
>> i want to show and print the numbers in arabic forms not in english,
>> called indian or farisy ..

Now I read this post, I am wonderring if you actually
meant 'farsi'.  Searches will go better with correctly
spelt search terms.  While I'm here, I will ask that
you put a single Upper Case letter at the start of
each sentence, to make it easier to read.

Signature

Andrew Thompson
http://www.athompson.info/andrew/

Oliver Wong - 11 Apr 2007 14:42 GMT
> while i searching about my problem i found this group and i hope to
> find solution for this problem, so let me tell you about my problem:
>
> i want to show and print the numbers in arabic forms not in english,
> called indian or farisy numbers,i can show the arabic words,so how can
> i convert or replase english numbers to arabic?

This code is off the top of my head, and not tested or compiled:

<code>
public static char convertToArabicDigit(int i) {
 switch(i) {
   case 0:
     return '\u0660';
   case 1:
     return '\u0661';
   case 2:
     return '\u0662';
   case 3:
     return '\u0663';
   case 4:
     return '\u0664';
   case 5:
     return '\u0665';
   case 6:
     return '\u0666';
   case 7:
     return '\u0667';
   case 8:
     return '\u0668';
   case 9:
     return '\u0669';
   default:
     throw new IllegalArgumentException();
 }
}
</code>

   - Oliver
Joshua Cranmer - 11 Apr 2007 22:27 GMT
>> while i searching about my problem i found this group and i hope to
>> find solution for this problem, so let me tell you about my problem:
[quoted text clipped - 35 lines]
>
>     - Oliver

Or the much shorter variant (w/o checking):
return 0x660 + i;
Lew - 12 Apr 2007 02:01 GMT
Oliver Wong wrote:
>> public static char convertToArabicDigit(int i) {
** snip **

> Or the much shorter variant (w/o checking):
> return 0x660 + i;

You'd need to downcast that to char, and presumably mask or error-check the
value of 'i'.

The switch variant is longer, but that is not important.  It's safer and,
chances are, faster.  And it's only significantly longer in the source code,
where length is not harmful.

A clever approach might use a Map< Integer, Character>.  "Clever" != "good".
("Clever" != "bad", but "clever" == "risky".)

Signature

Lew

Joshua Cranmer - 12 Apr 2007 03:26 GMT
> Oliver Wong wrote:
>>> public static char convertToArabicDigit(int i) {
[quoted text clipped - 12 lines]
> A clever approach might use a Map< Integer, Character>.  "Clever" !=
> "good". ("Clever" != "bad", but "clever" == "risky".)

Switches are not necessarily faster: take converting '0' to 0:

The probable fastest is way is (char)(c & 0xf) - it is a simple bit
mask. A switch, by contrast, is probably at best going to calculate an
offset and then load a value to return.

Changing numeric numbers by manipulating the relative zero character
makes the most sense to me, because of the way Unicode treats digits. It
is easiest for me to see '(Farsi 0)' + i and recognize what it does as
opposed to a switch with '(Farsi 0)' ... '(Farsi 9)', simply because
that's how I process information.

To each his own, I guess.
Lew - 12 Apr 2007 13:10 GMT
> The probable fastest is way is (char)(c & 0xf) - it is a simple bit
> mask. A switch, by contrast, is probably at best going to calculate an
> offset and then load a value to return.

First, char is 16 bits wide, so don't you mean
(char) (c & 0xffff)?

Second, code points aren't always exactly 16 bits wide.  I don't even know if
that affects this matter but it might affect someone parsing a String.

Signature

Lew

الصباغ - 14 Apr 2007 17:49 GMT
> "ÇáÕÈÇÛ" <sabd1...@yahoo.com> wrote in message
>
[quoted text clipped - 39 lines]
>
>     - Oliver

i would like to thank you for you help... i tryed your code... but the
returned result well be ? for any number... my operating system is
windows xp and i using jbuilder7 for writing and testing java codes...
i think your code is correct but the problem in unicode... can you
tell me how can i make my program accept the '\u066*' unicode and what
is the main name of this unicode?

thank you very much.
Lew - 14 Apr 2007 20:26 GMT
> i would like to thank you for you help... i tryed your code... but the
> returned result well be ? for any number... my operating system is
> windows xp and i using jbuilder7 for writing and testing java codes...
> i think your code is correct but the problem in unicode... can you
> tell me how can i make my program accept the '\u066*' unicode and what
> is the main name of this unicode?

The problem might not be the code but the font you use to display the result.

Java programs must accept '\u' characters by definition, so that cannot be the
problem.

Also, if you are receiving Strings from external sources, or sending them to
external sources, be aware of encoding issues.

Signature

Lew

Oliver Wong - 16 Apr 2007 14:49 GMT
> i would like to thank you for you help... i tryed your code... but the
> returned result well be ? for any number... my operating system is
> windows xp and i using jbuilder7 for writing and testing java codes...

   Where are you seeing these "?" characters? Are you using
System.out.println() to display them? If so, the problem may be that your
console doesn't support displaying Arabic characters. As a test, you can
try writing the characters to a file (using a suitable encoding such as
UTF-8 -- ASCII would *not* be suitable), and then using a hex editor to
open the file and check that the correct set of bytes were written.

> i think your code is correct but the problem in unicode... can you
> tell me how can i make my program accept the '\u066*' unicode

   As Lew mentioned, part of the Java specification requires all
compilers to accept the '\u066*' codes, so that probably isn't an issue
worth investigating.

> and what
> is the main name of this unicode?

   Not sure I understand this question. I got the information from the
PDF file at http://www.unicode.org/charts/PDF/U0600.pdf and these sequence
of characters are titled "Arabic-Indic digits". Below that, they write
"These digits are used with Arabic proper; for languages of Iran,
Pakistan, and India, see the Eastern Arabic-Indic digits at 06F0..06F9."
The characters themselves are named "ARABIC-INDIC DIGIT ZERO",
"ARABIC-INDIC DIGIT ONE", etc.

   - Oliver
Chris Uppal - 12 Apr 2007 13:32 GMT
ÇáÕÈÇÛ wrote:

> i want to show and print the numbers in arabic forms not in english,
> called indian or farisy numbers,i can show the arabic words,so how can
> i convert or replase english numbers to arabic?

Look into class
   java.awt.font.NumericShaper
Specifically, the shape() method(s).

I have never used it myself, but as far as I can tell from the JavaDoc, it is
intended for just that purpose.

   -- chris


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.