天道酬勤,学无止境

chinese-locale

Language codes for simplified Chinese and traditional Chinese?

Question We are creating multi-language subsites on our website. I would like to use the 2-letter language codes. Spanish and French are easy. They will get URLs like: mydomain.com/es mydomain.com/fr but I run into a problem with Traditional and Simplified chinese. Are there standards for which 2 letter codes to use for these languages? mydomain.com/zh mydomain.com/? Answer1 @dkarp gives an excellent general answer. I will add some additional specifics regarding Chinese: There are several countries where Chinese is the main written language. The major difference between them is whether they

2021-10-21 17:57:51    分类:技术分享    utf-8   internationalization   cjk   chinese-locale

How to display chinese characters in PDF using ITextSharp in c#?

Question I want to display one word of chinese characters in PDF along with english characters. Currently chinese characters are not getting displayed in PDF.I have used itextsharp to generate pdf with contents.I have tried some chinese fonts but not working. How to show chinese characters along with english characters in PDF using itextsharp? var docIndex = new Document(new Rectangle(792, 612)); var writer = PdfWriter.GetInstance(docIndex, new FileStream(Server.MapPath("~") + "/pdf/Project-" + report.pulledId + currentTime + ".pdf", FileMode.Create)); docIndex.Open(); FontFactory.Register("c

2021-10-19 22:58:24    分类:技术分享    c#   pdf   itext   chinese-locale

How to use mPDF for Chinese Language

Question I am using mPDF to save form input data to PDF. For English, it is working fine. Anyone can use this code to save HTML Form data to PDF. Issue: In order to fulfill my project requirement I need to use the Chinese Language. My current code is not working for that. Form.html <form action='processPDF.php' method='post'> <label for="name">Name</label> <input name="name" type="text" id="name"> <input type='submit' name='submit' value='Download PDF'> </form> processPDF.php <?php header('Content-Type: text/html; charset=UTF-8'); if (isset($_POST['submit'])) { if (isset($_POST['name'])) {

2021-10-19 21:47:17    分类:技术分享    php   html   pdf   mpdf   chinese-locale

.NET Chinese CultureInfo "zh" does not exist?

Question I'm using .NET 3.5 and running the following code: var culture = new CultureInfo("zh"); // Throws ArgumentException I got the string "zh" from an xml:lang attribute. I don't understand why an exception is thrown, because for instance "de" (wich is parent for "de-DE") is working fine. The culture "zh-CN" does work, but thats nothing that I can use. Edit: It works on .NET 4.5.1 (thanks to xanatos) - so even if the MSDN page explains that Chinese is an exception, the behaviour is different in newer .NET versions. Answer1 There is a small note on the CultureInfo page: There are two

2021-10-14 16:49:41    分类:技术分享    c#   cultureinfo   chinese-locale

How to read Chinese files?

Question I'm stuck with all this confusing encoding stuff. I have a file containing Chinese subs. I actually believe it is UTF-8 because using this in Notepad++ gives me a very good result. If I set gb2312 the Chinese part is still fine, but I will see some UTF8 code not being converted. The goal is to loop through the text in the file and count how many times the different chars come up. import os import re import io character_dict = {} for dirname, dirnames, filenames in os.walk('.'): for filename in filenames: if "srt" in filename: import codecs f = codecs.open(filename, 'r', 'gb2312'

2021-09-30 21:06:13    分类:技术分享    python   unicode   utf-8   chinese-locale

parsing chinese characters in java showing weird behaviour

Question I am having a csv file which has some fields having chinese character strings. Unfortunately i dont know what is encoding of this input csv file. I am trying to read this input csv and using selective fields from it, i am making a html and another csv file as output. While reading csv input, i tried all encoding from list http://docs.oracle.com/javase/7/docs/technotes/guides/intl/encoding.doc.html which have Chinese mentioned in their description. And found if I use InputStreamReader read = new InputStreamReader(filepath,"GB18030"); for reading csv and OutputStreamWriter osW=new

2021-09-29 01:11:17    分类:技术分享    java   string   character-encoding   chinese-locale

Showing navigator.geolocation.getCurrentPosition in Baidu Maps

Question We know that due to the infamous China GPS offset problem, GPS (WSG-84) map coordinates don't correspond exactly to the coordinate system that state-approved Chinese maps use (GCJ-02). The question is, how does one make sure that placing a marker via the Baidu Maps API at the coordinates reported by navigator.geolocation.getCurrentPosition() will match reality? Would the GPS chip of a device manufactured or approved for use in China return coordinates that don't match the actual position of a user, in order to instead match he GJC-02 maps? Does it matter if the user runs a Chinese

2021-09-19 20:39:51    分类:技术分享    javascript   google-maps   geolocation   chinese-locale   baidu

How to use Google's Text-to-Speech service for Chinese characters on Android?

Question I'm trying to pull an audio file from google's text-to-speech function. Basically, you toss in the link and then concat whatever you want to be spoken at the end of it. I've gotten the below code to work just fine for English, so I think the problem must be how the Chinese characters are getting encoded in the request. Here's what I've got: String text = "text to be spoken"; public static final String AUDIO_CHINESE= "http://www.translate.google.com/translate_tts?tl=zh&q="; public static final String AUDIO_ENGLISH = "http://www.translate.google.com/translate_tts?tl=en&q="; URL url =

2021-09-18 08:44:05    分类:技术分享    java   android   url   url-encoding   chinese-locale

How to display Chinese characters inside a pandas dataframe?

Question I can read a csv file in which there is a column containing Chinese characters (other columns are English and numbers). However, Chinese characters don't display correctly. see photo below I loaded the csv file with pd.read_csv(). Either display(data06_16) or data06_16.head() won't display Chinese characters correctly. I tried to add the following lines into my .bash_profile: export LC_ALL=zh_CN.UTF-8 export LANG=zh_CN.UTF-8 export LC_ALL=en_US.UTF-8 export LANG=en_US.UTF-8 but it doesn't help. Also I have tried to add encoding arg to pd.read_csv(): pd.read_csv('data.csv', encoding=

2021-06-25 04:42:12    分类:技术分享    python   csv   pandas   encoding   chinese-locale

ReportLab: working with Chinese/Unicode characters

Question TL;DR: Is there some way of telling ReportLab to use a specific font, and fallback to another if glyphs for some characters are missing? Alternatively, Do you know of a condensed TrueType font which contains the glyphs for all European languages, Hebrew, Russian, Chinese, Japanese and Arabic? I've been creating reports with ReportLab, and have encountered problems with rendering strings containing Chinese characters. The font I've been using is DejaVu Sans Condensed, which does not contain the glyphs for Chinese (however, it does contain Cyrillic, Hebrew, Arabic and all sorts of

2021-06-23 14:24:27    分类:技术分享    python   unicode   fonts   reportlab   chinese-locale