Page 1 of 1

Encoding of multilanguage file

Posted: Wed Feb 27, 2008 8:29 pm
by import
What is the encoding of multilanguage file? I wanted to translate JFileUpload to Russian, but I failed :(

Re: Encoding of multilanguage file

Posted: Wed Feb 27, 2008 8:30 pm
by import
Translate i18n.properties in russian and then use native2ascii Java tool to convert your file with \u unicode chars. If you don't know how to then send your file to support(at)jfileupload(dot)com and they will run native2ascii for you.

Re: Encoding of multilanguage file

Posted: Mon Jan 18, 2010 3:05 pm
by vlad
I'm having trouble translating the interface to Russian.

I've converted the UTF-8 file to ASCII:

Code: Select all

taskoutput.usage=\u00d0\u0178\u00d0\u00b5\u00d1\u20ac\u00d0\u00b5\u00d1\u201a\u00d0\u00b0\u00d1\u2030\u00d0\u00b8\u00d1\u201a\u00d0\u00b5 \u00d1\u201e\u00d0\u00b0\u00d0\u00b9\u00d0\u00bb\u00d1\u2039 \u00d1\ufffd \u00d0\u00b2\u00d0\u00b0\u00d1\u02c6\u00d0\u00b5\u00d0\u00b3\u00d0\u00be \u00d0\u00ba\u00d0\u00be\u00d0\u00bc\u00d0\u00bf\u00d1\u0152\u00d1\u017d\u00d1\u201a\u00d0\u00b5\u00d1\u20ac\u00d0\u00b0
but I get:

Code: Select all

Перетащите файлы � вашего компьютера
Any other language seems to work fine. Please help.

Re: Encoding of multilanguage file

Posted: Mon Jan 18, 2010 8:14 pm
by support
Did you specify the encoding for incoming file on native2ascii.exe command line ?

Re: Encoding of multilanguage file

Posted: Mon Jan 18, 2010 10:57 pm
by vlad
Thanks for the tip, it worked. I had a UTF-8 encoded file, so the following command worked for me:

Code: Select all

native2ascii.exe -encoding UTF-8 inputfilename.txt outputfilename.txt
.. if anybody else has this problem.

Re: Encoding of multilanguage file

Posted: Thu Jan 21, 2010 1:14 pm
by vlad
If you use PHP dynamically generated language files, you could use the following function to convert from UTF-8 to Unicode code points on the fly, without using Java's utility:

Code: Select all

function utf8_to_unicode($str) {
	$unicode = array();
	$values = array();
	$lookingFor = 1;
	
	for ($i = 0; $i < strlen($str); $i++ ) {
		if ($str[$i] == " ") {
			$unicode[] = " ";
		} else {
			$thisValue = ord( $str[ $i ] );
			if ( $thisValue < ord('A') ) {
				// exclude 0-9
				if ($thisValue >= ord('0') && $thisValue <= ord('9')) {
					// number
					$unicode[] = chr($thisValue);
				}
				else {
					$unicode[] = '\\'.dechex($thisValue);
				}
			} else {
				if ($thisValue < 128){
					$unicode[] = $str[ $i ];
				} else {
					if ( count( $values ) == 0 ) $lookingFor = ( $thisValue < 224 ) ? 2 : 3;
					$values[] = $thisValue;
					if ( count( $values ) == $lookingFor ) {
						$number = ( $lookingFor == 3 ) ?
						( ( $values[0] % 16 ) * 4096 ) + ( ( $values[1] % 64 ) * 64 ) + ( $values[2] % 64 ):
						( ( $values[0] % 32 ) * 64 ) + ( $values[1] % 64 );
						$number = dechex($number);
						$unicode[] = (strlen($number)==3)?"\\u0".$number:"\\u".$number;
						$values = array();
						$lookingFor = 1;
					} // if
				} // if
			}
		}
	} // for
	return implode("", $unicode);
}
P.S. It seems to me that would have been more professional if the Java applet would have simply supported UTF-8 characters, than having to use this workaround.

Re: Encoding of multilanguage file

Posted: Sun Jan 24, 2010 11:55 am
by support
Thanks for the tip.