Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support multi language #52

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 59 additions & 2 deletions jquery.base64.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,59 @@ jQuery.base64 = ( function( $ ) {
_VERSION = "1.0";


// add by nathanielwen
function _utf16ToUtf8( s ) {
var code,
x = [];
for (var i = 0; i < s.length; i++) {
code = s.charCodeAt(i);
if(code > 0x0 && code <= 0x7f){
x.push(s.charAt(i));
}else if(code >= 0x80 && code <= 0x7ff){
x.push(
String.fromCharCode(0xc0 | ((code >> 6) & 0x1f)),
String.fromCharCode(0x80 | ((code >> 0) & 0x3f))
);
}else{
x.push(
String.fromCharCode(0xe0 | ((code >> 12) & 0x0f)),
String.fromCharCode(0x80 | ((code >> 6) & 0x3f)),
String.fromCharCode(0x80 | ((code >> 0) & 0x3f))
);
}
}
return x.join( "" );
}

// add by nathanielwen
function _utf8ToUtf16( s ) {
var c, c2, c3,
x = [];
for (var i = 0; i < s.length; i++) {
c = s.charCodeAt(i);
switch(c >> 4){
case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7:
x.push(s.charAt(i));
break;
case 12: case 13:
c2 = s.charCodeAt(++i);
x.push(
String.fromCharCode(((c & 0x1F) << 6) | (c2 & 0x3F))
)
break;
case 14:
c2 = s.charCodeAt(++i);
c3 = s.charCodeAt(++i);
x.push(
String.fromCharCode(((c & 0x0F) << 12) | ((c2 & 0x3F) << 6) | ((c3 & 0x3F) << 0))
)
break;
}
}
return x.join( "" );
}


function _getbyte64( s, i ) {
// This is oddly fast, except on Chrome/V8.
// Minimal or no improvement in performance by using a
Expand Down Expand Up @@ -125,7 +178,9 @@ jQuery.base64 = ( function( $ ) {
break;
}

return x.join( "" );
// add by nathanielwen
var _t = x.join( "" );
return _utf8ToUtf16( t );
}


Expand All @@ -144,7 +199,9 @@ jQuery.base64 = ( function( $ ) {
if ( arguments.length !== 1 ) {
throw "SyntaxError: exactly one argument required";
}


// add by nathanielwen
s = _utf16ToUtf8( s )
s = String( s );

var i,
Expand Down
2 changes: 2 additions & 0 deletions tableExport.js
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,8 @@ THE SOFTWARE.*/
}

var excelFile = "<html xmlns:o='urn:schemas-microsoft-com:office:office' xmlns:x='urn:schemas-microsoft-com:office:"+defaults.type+"' xmlns='http://www.w3.org/TR/REC-html40'>";
// add by nathanielwen
excelFile += '<meta http-equiv="content-type" content="application/vnd.ms-' + defaults.type + '; charset=UTF-8">';
excelFile += "<head>";
excelFile += "<!--[if gte mso 9]>";
excelFile += "<xml>";
Expand Down