String operation script help needed!

Teren

One of Freddy's beloved
Joined
Dec 22, 2003
Messages
585
Hello.

I'm making a script atm, which converts Katakana and Hiragana to Romaji. It's very simple, you type the text in to a form and then the script uses str_replace() to replace japanese characters to roman transliterations. It works ok, but I can't think of a way to convert a special symbol.

Let's say the symbol is "-" (no quotes) and this word is in japanese: fa-tie. If you didn't understand what it means, the symbol makes the next symbol double, (we can say it turns to the symbol on the right to it). Anyone has an idea how to make that symbol work?

Also the is another symbol that is the same as that one, but it turns in to the letter on the left to it.

Thanks in advance, Teren.
 

Teren

One of Freddy's beloved
Joined
Dec 22, 2003
Messages
585
I personally think it should be done before the conversions, the symbol should just change itself to the corresponding symbol, not the transliteration, because it will get converted later in the script anyway :)
 

Teren

One of Freddy's beloved
Joined
Dec 22, 2003
Messages
585
Heh, I solved the problem myself!

Here's how I've done it if anyone is interested:
p.s. the capital "y" is never used in my converter, it's done after the transliteration
PHP:
$text = str_replace("The symbol", "Y", $text);
	while(strpos($text, 'Y') !== false) {
		$pos = strpos($text, 'Y');
		$letter = substr($text, ($pos + 1), 1);
		$text = substr_replace($text, $letter, $pos, 1);
	}
 

Teren

One of Freddy's beloved
Joined
Dec 22, 2003
Messages
585
Lmao, I just noticed I forgot to say im using php :D
 

Users who are viewing this thread

Top Bottom