encoding - Why does jQuery get() strip out special characters from csv file? -
i'm trying bring in csv javascript munch on , spit out on html page. csv has special characters ½ , ×. according firebug, when put breakpoint inside callback of $.get(), looks there special characters missing. replaced sort of whitespace displays question mark or box if copy , past program.
i have tried
$.ajaxsetup({ datatype: "text" , contenttype: "text/plain; charset=utf-8" });
and other variations. doctype of webpage utf-8. have tried 8859-1. nothing far has worked.
edit: placing characters hand html either or using html entity codes works fine. placing them javascript works too. problem reading csv file.
edit2: try this. create text file in Öç¼»
. create webpage so...
<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script> <script type="text/javascript"> $.get("encodeme.txt", function(data){ console.log(data); }) </script> </head> <body> </body> </html>
all logged whitespace , chinese character: �缻
. notice whitespace appears qestion mark thingy when copypaste it.
blah! should have seen sooner. problem csv file encoded ansi. did briefly @ file in notepad++ , should have noticed problem there foolishly missed first time. selected format > convert utf-8 in notepad++ , works fine. marc b closest answering question, although didn't post answer reason. now, how openoffice encode files correctly...
Comments
Post a Comment