Ask Question Forum:
Model Library:2025-02-08 Updated:A.I. model is online for auto reply question page
C
O
M
P
U
T
E
R
2
8
Show
#
ASK
RECENT
←
- Underline
- Bold
- Italic
- Indent
- Step
- Bullet
- Quote
- Cut
- Copy
- Paste
- Table
- Spelling
- Find & Replace
- Undo
- Redo
- Link
- Attach
- Clear
- Code
Below area will not be traslated by Google,you can input code or other languages
Hint:If find spelling error, You need to correct it,1 by 1 or ignore it (code area won't be checked).
X-position of the mouse cursor
Y-position of the mouse cursor
Y-position of the mouse cursor
Testcursor
caretPos
Attachment:===
Asked by duncanb7
at 2024-04-10 08:55:00
Point:250 Replies:12 POST_ID:828467USER_ID:11059
Topic:
JavaScript;Microsoft Excel Spreadsheet Software;Visual Basic Programming
I get one csv file in which has some chinese character and use following javascript code
to form a table. the table is displayed for number and Engish value is fine but it doesn't
display correct chinese character according to the cells postion in csv file. it display a strange output on
some cells. I heard people said javascript is not able to handle Chinese character or
other country character. Is it True? Is ther any method to overcome this?
Whether I need to convert the chinese character into unicode first and then put it back int csv file before
any javascript processing ?
http://code.cside.com/3rdpage/us/unicode/converter.html
Please advise
Duncan
to form a table. the table is displayed for number and Engish value is fine but it doesn't
display correct chinese character according to the cells postion in csv file. it display a strange output on
some cells. I heard people said javascript is not able to handle Chinese character or
other country character. Is it True? Is ther any method to overcome this?
Whether I need to convert the chinese character into unicode first and then put it back int csv file before
any javascript processing ?
http://code.cside.com/3rdpage/us/unicode/converter.html
Please advise
Duncan
<!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" /><title>Untitled Document</title><script language="javascript"> function getData( url ) { var xmlhttp; if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { renderData( xmlhttp.responseText ); } } xmlhttp.open("GET","postcodes.csv",true); xmlhttp.send(); } function renderData( data ) { var dataRows = data.split( "" ); var table = document.createElement("Table"); table.border = 0.5; for( i = 0; i < dataRows.length; i++ ) { var tableRow = table.insertRow(i); var dataCells = dataRows[i].split(","); for( j = 0; j < dataCells.length; j++ ) { var tableCell= tableRow.insertCell(j); tableCell.innerHTML = dataCells[j]; } } document.body.appendChild( table ); } getData();</script></head><body></body></html>Toggle HighlightingOpen in New WindowSelect AllAccept Multiple Solutions Accept as Solution 1:2:3:4:5:6:7:8:9:10:11:12:13:14:15:16:17:18:19:20:21:22:23:24:25:26:27:28:29:30:31:32:33:34:35:36:37:38:39:40:41:42:43:44:45:46:47:48:49:50:51:52:53:54:55:56:57:58:
Author: duncanb7 replied at 2024-04-11 11:03:39
Thanks for your reply
If I put the &# Unciode in csv file
like this, it display back all
chinese character by Javascript
Hello,嶬剶卜
good, day
1,2,3,4,4
5,6,7,8
If I put the &# Unciode in csv file
like this, it display back all
chinese character by Javascript
Hello,嶬剶卜
good, day
1,2,3,4,4
5,6,7,8
Author: duncanb7 replied at 2024-04-11 01:06:48
Thanks,
I think I could do VBA code accroding the javascript code provide by myself
but others can reply it, it is really welecom and thanks
Duncan
I think I could do VBA code accroding the javascript code provide by myself
but others can reply it, it is really welecom and thanks
Duncan
Expert: Michel Plungjan replied at 2024-04-11 01:02:26
No. Sorry. I added the VBA zone for you
Author: duncanb7 replied at 2024-04-11 00:27:44
Sorry it is in javascript not in vba
Could you help provide a code for Vba
Could you help provide a code for Vba
Author: duncanb7 replied at 2024-04-11 00:22:03
Finally, get the function to convert the chinese character to Unicode
http://www.blog.highub.com/javascript/javascript-advanced/convert-chinese-characters-to-unicode/
http://www.blog.highub.com/javascript/javascript-advanced/convert-chinese-characters-to-unicode/
Author: duncanb7 replied at 2024-04-10 23:48:14
But how to convert chinese charter to &#aaaaa in vba ?
Author: duncanb7 replied at 2024-04-10 23:47:15
I read it before, and now I understand &#aaaa, where a is for decimal code, ubbbb, where b is for hex code
the question how I convert it to &# or u in vba so, the text file will
be
After new conversion, book9.csv will be like this
=================================
Hello, 嶬剶卜, good, day,
1,2,3,4,4
5,6,7,8
================================
In other words, I use above function of csvtoUTF8() is incorrect. ?
the question how I convert it to &# or u in vba so, the text file will
be
After new conversion, book9.csv will be like this
=================================
Hello, 嶬剶卜, good, day,
1,2,3,4,4
5,6,7,8
================================
In other words, I use above function of csvtoUTF8() is incorrect. ?
Assisted Solution
Expert: Michel Plungjan replied at 2024-04-10 23:31:25
75 points GOOD
Author: duncanb7 replied at 2024-04-10 22:48:33
RE-send it for typing mistake , I goolge it for whole day, finally get the method to convert csv file into UFT-8 in vba and
find the linke at
http://code.cside.com/3rdpage/us/unicode/converter.html
the book9.csv(after encode) is still not matched from note++ to the link conversion above.
What is &# stand for, it mean UTF code ?
What is u stand for, it means classical Unicode ?
Question-1, I use notepad to view the conversion file of boo9.csv with option to UTF8
the hex code in notepad is different from hex code with &# and u , Why ?
QUestion-2 Since by question-1 problem, so I try to convert one character from
the link, and then use decodeURIComponent( escape(&#xxxx ) ) it works and display right character in javascript
but decodeURIComponent( escape(uxxxxx ) ) is not displayed the correct character,
What is stand for HTML Unicode and Java Unicode in the link ?
Question-3, SHould I set <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
in my javascript ?
VBA code for book8.csv convert to book9.csv in UTF-8
===========================================
Sub csvtoUTF8()
Dim sfol As String
Dim dfol As String
sfol = ActiveWorkbook.path & ""
dfol = sfol
Call CopyFile2File(sfol, "book8.csv", dfol, "book9.csv")
Call Encode(sfol & "book9.csv", "UTF-8")
End Sub
Sub Encode(ByVal sPath$, Optional SetChar$ = "UTF-8")
With CreateObject("ADODB.Stream")
.Open
.LoadFromFile sPath ' Loads a File
.Charset = SetChar ' sets stream encoding (UTF-8)
.SaveToFile sPath, 2 ' adSaveCreateOverWrite
.Close
End With
End Sub
find the linke at
http://code.cside.com/3rdpage/us/unicode/converter.html
the book9.csv(after encode) is still not matched from note++ to the link conversion above.
What is &# stand for, it mean UTF code ?
What is u stand for, it means classical Unicode ?
Question-1, I use notepad to view the conversion file of boo9.csv with option to UTF8
the hex code in notepad is different from hex code with &# and u , Why ?
QUestion-2 Since by question-1 problem, so I try to convert one character from
the link, and then use decodeURIComponent( escape(&#xxxx ) ) it works and display right character in javascript
but decodeURIComponent( escape(uxxxxx ) ) is not displayed the correct character,
What is stand for HTML Unicode and Java Unicode in the link ?
Question-3, SHould I set <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
in my javascript ?
VBA code for book8.csv convert to book9.csv in UTF-8
===========================================
Sub csvtoUTF8()
Dim sfol As String
Dim dfol As String
sfol = ActiveWorkbook.path & ""
dfol = sfol
Call CopyFile2File(sfol, "book8.csv", dfol, "book9.csv")
Call Encode(sfol & "book9.csv", "UTF-8")
End Sub
Sub Encode(ByVal sPath$, Optional SetChar$ = "UTF-8")
With CreateObject("ADODB.Stream")
.Open
.LoadFromFile sPath ' Loads a File
.Charset = SetChar ' sets stream encoding (UTF-8)
.SaveToFile sPath, 2 ' adSaveCreateOverWrite
.Close
End With
End Sub
Author: duncanb7 replied at 2024-04-10 22:46:51
I goolge it for whole day, finally get the method to convert csv file into UFT-8 in vba and
find the linke at
http://code.cside.com/3rdpage/us/unicode/converter.htmlSub csvtoUTF8()
the book9.csv(after encode) is still not matched from note++ to the link conversion above.
What is &# stand for, it mean UTF code ?
What is u stand for, it means classical Unicode ?
Question-1, I use notepad to view the conversion file of boo9.csv with option to UTF8
the hex code in notepad is different from hex code with &# and u , Why ?
QUestion-2 Since by question-1 problem, so I try to convert one character from
the link, and then use decodeURIComponent( escape(&#xxxx ) ) it works and display right character in javascript
but decodeURIComponent( escape(uxxxxx ) ) is not displayed the correct character,
What is stand for HTML Unicode and Java Unicode in the link ?
Question-3, SHould I set <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
in my javascript ?
VBA code for book8.csv convert to book9.csv in UTF-8
===========================================
Dim sfol As String
Dim dfol As String
sfol = ActiveWorkbook.path & ""
dfol = sfol
Call CopyFile2File(sfol, "book8.csv", dfol, "book9.csv")
Call Encode(sfol & "book9.csv", "UTF-8")
End Sub
Sub Encode(ByVal sPath$, Optional SetChar$ = "UTF-8")
With CreateObject("ADODB.Stream")
.Open
.LoadFromFile sPath ' Loads a File
.Charset = SetChar ' sets stream encoding (UTF-8)
.SaveToFile sPath, 2 ' adSaveCreateOverWrite
.Close
End With
End Sub
find the linke at
http://code.cside.com/3rdpage/us/unicode/converter.htmlSub csvtoUTF8()
the book9.csv(after encode) is still not matched from note++ to the link conversion above.
What is &# stand for, it mean UTF code ?
What is u stand for, it means classical Unicode ?
Question-1, I use notepad to view the conversion file of boo9.csv with option to UTF8
the hex code in notepad is different from hex code with &# and u , Why ?
QUestion-2 Since by question-1 problem, so I try to convert one character from
the link, and then use decodeURIComponent( escape(&#xxxx ) ) it works and display right character in javascript
but decodeURIComponent( escape(uxxxxx ) ) is not displayed the correct character,
What is stand for HTML Unicode and Java Unicode in the link ?
Question-3, SHould I set <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
in my javascript ?
VBA code for book8.csv convert to book9.csv in UTF-8
===========================================
Dim sfol As String
Dim dfol As String
sfol = ActiveWorkbook.path & ""
dfol = sfol
Call CopyFile2File(sfol, "book8.csv", dfol, "book9.csv")
Call Encode(sfol & "book9.csv", "UTF-8")
End Sub
Sub Encode(ByVal sPath$, Optional SetChar$ = "UTF-8")
With CreateObject("ADODB.Stream")
.Open
.LoadFromFile sPath ' Loads a File
.Charset = SetChar ' sets stream encoding (UTF-8)
.SaveToFile sPath, 2 ' adSaveCreateOverWrite
.Close
End With
End Sub
Assisted Solution
Expert: Michel Plungjan replied at 2024-04-10 21:15:48
75 points GOOD
The file needs to be saved as UTF8 and the page you are showing it in too. Alternatively convert to unicode uxxxx which JS should be able to show regardless of page encoding
Accepted Solution
Expert: jimyX replied at 2024-04-10 21:12:58
100 points GOOD
Please have a look on this article:
http://blogs.sun.com/shankar/entry/how_to_handle_utf_8
http://blogs.sun.com/shankar/entry/how_to_handle_utf_8