javascript - String comparison of Japanese characters -
i need 2 compare strings see if same value, both strings in japanese. check seems fail , assume it's shortcoming of javascript , utf-8. should expected succeed? , how can make work? can javascript convert strings \x{57fc}
perform comparison on?
var foo = '郵便番号', bar = '郵便番号'; if(foo == bar){ console.log('they same'); }
update
it appears works fine, failure bigger issue backbone validation. answers.
you forgot quotes on strings!
run current code browser console open, , you'll see referenceerror due missing quotes (the interpreter think 郵便番号
identifier, not string).
wrap strings in proper quotes, , works, javascript can handle utf-8 fine:
var foo = '郵便番号', bar = '郵便番号'; if(foo == bar){ console.log('they same'); }
regarding second question, can use '\u57fc'
, don't need to; it's same literal '埼'
.
Comments
Post a Comment