From b0f21fcf119ca1c54cdc3e37a1c61e29c58c2798 Mon Sep 17 00:00:00 2001 From: erdgeist <> Date: Wed, 11 Jun 2008 18:05:27 +0000 Subject: Save some serious memory on the lower half of each charset. Also make mapping lookup more elegant. --- encoding_jis.js | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) (limited to 'encoding_jis.js') diff --git a/encoding_jis.js b/encoding_jis.js index d807385..c6152d4 100644 --- a/encoding_jis.js +++ b/encoding_jis.js @@ -5,25 +5,31 @@ // the amount of 19968 to save 5kBytes in this script, so the // actual value is 19968 + encoding_jis_0208_1[ x ] +var page = { + us_ascii : 0, + jis0208 : 1, + jis0201 : 2 +}; + function decode_jis( str ) { var outstring = ""; - var cur_page = "us-ascii"; + var cur_page = page.us_ascii; for( i=0; i= 0x20 && x <= 0xdf ) { append = String.fromCharCode( encoding_jis_0201[ off - 32 ] ); } break; - case "jis0208": + case page.jis0208: if( i>str.length-1 ) { return outstring + append; } var x0 = ( str.charCodeAt( i++ ) - 0x21 ) & 0xff; var x1 = ( str.charCodeAt( i ) - 0x21 ) & 0xff; -- cgit v1.2.3