Function to convert special characters?

L

laredotornado

Hello, We are using Java 1.4 on Solaris. Does anyone know of a
function, or can create one, that will take a string and return a
version where accented vowels are replaced with normal vowels. For
example, you may have a string

String s1 = "résumé";

s2 = fn(s1);

System.out.println(s2); // prints "resume" (where e appears instead
of é)

Thanks, - Dave
 
R

Raghu Kaippully

Hello, We are using Java 1.4 on Solaris. Does anyone know of a
function, or can create one, that will take a string and return a
version where accented vowels are replaced with normal vowels.

Have you taken a look at Java API docs?
 
R

Roedy Green

String s1 = "résumé";

I think your easiest way to do it is to write a translate table.

You index by letter to get the replacement letter.

You compose the TRT by initialising it with the null translation, i.e.
x -> x.

Then you manually fill it in with the index of the accented letters to
the corresponding unaccented.

that is all done in static init.

Then to convert a string, you convert to a char[], convert char by
char by indexing in your array and convert back to string.

You can prune the table to deal with only part of the range and leave
the rest e.g. the Chinese band untranslated.

This function is built-in to Abundance, but that was in the days of
DOS and the char set was only 256 letters. I could give you the FORTH
code, but that probably would not be that useful.
 
B

Boudewijn Dijkstra

You compose the TRT by initialising it with the null translation, i.e.
x -> x.

I thought the null translation was x -> 0, but the union translation is x ->
x.
 
R

Roedy Green

I thought the null translation was x -> 0, but the union translation is x ->
x.

Hmm, what the fancy mathematical word for a element that maps onto
itself?
 
C

Chris Head

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Roedy said:
Hmm, what the fancy mathematical word for a element that maps onto
itself?

Identity translation?

Chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (MingW32)

iD8DBQFDGJrB6ZGQ8LKA8nwRAk1hAKCDhQ3XT1FWrJf27Mq72AexqZAu4gCgj3sd
RcyZphqs3H+LgrugbfZNoV8=
=W2Kz
-----END PGP SIGNATURE-----
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top