Here I'm trying to flip an English letter upside down for my mail template.
Well I can get it manually. What I'm doing is now manually
just like
content.append("ɥ"); //actual h letter.
content.append("ǝ")// actual e letter.
So my question is that , is there any trick/method/any clue to do it in programmatic way ?
What I'm doing now is
switch(letter) {
case 'e':
return 'ǝ';
}
That looks odd and looking for hints. Thanks for any help.
I'm not sure of a java-specific solution, but seeing as Strings in java use unicode, I checked out the unicode characters for their upside down counterparts here: http://www.fileformat.info/convert/text/upside-down-map.htm
It doesn't look there's a good programmatic method for finding these. However, there are a variety of converters, like this one http://www.fileformat.info/convert/text/upside-down.htm You could generate config files based on input and output of one of these types of converters and use those config files to drive your upside-down letter selection
The fastest way to do character replacement is an array.
create an array of upside down letters. Then, do a check of the value coming in and find it's match.
Java allows you to get the integer representation of a character by simply casting int x = char a;
So, it stands to reason that your upsidedown a would be at the index of your char minus the lowest char you are mapping (usually lowercase a).
char[] updown = {'ɐ','q','ɔ','p','ə','ɟ','ƃ','ɥ','ı','ɾ','ʞ','l','ɯ','u','o','d','b','ɹ','s','ʇ','n','ʌ','ʍ','x','ʎ','z'};
//this example uses 26 chars, all lower case;
int a = 'a';
int z = 'z';
String newString = "";
for(int i=0; i<string.length; i++){
int ch = string.charAt(i);
if(ch>= a && ch <=z){
newString = (updown[ch-a]) + newString;
}
}
Here's a link to IDEONE where you can compile and test for yourself. http://ideone.com/LombFE
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With