Questions tagged [gbk]

GBK is an extension of the GB2312 character set for simplified Chinese characters, used in the People's Republic of China.

47 questions
5
votes
2 answers

why does file.tell() affect encoding?

Calling tell() while reading a GBK-encoded file of mine causes the next call to readline() to raise a UnicodeDecodeError. However, if I don't call tell(), it doesn't raise this error. C:\tmp>hexdump badtell.txt 000000: 61 20 6B 0D 0A D2 BB B0-E3 …
mfmain
  • 99
  • 6
5
votes
2 answers

Print a list that contains Chinese characters in Python

My code looks like : # -*- coding: utf-8 -*- print ["asdf", "中文"] print ["中文"] print "中文" The output in the Eclipse console is very strange: ['asdf', '\xe4\xb8\xad\xe6\x96\x87'] ['\xe4\xb8\xad\xe6\x96\x87'] 中文 My first question is: why did the…
user958547
4
votes
2 answers

How to encode Chinese character as 'gbk' in json, to format a url request parameter String?

I want to dump a dict as a json String which contains some Chinese characters, and format a url request parameter with that. here is my python code: import httplib import simplejson as json import urllib d={ "key":"上海", "num":1 } jsonStr =…
armnotstrong
  • 8,605
  • 16
  • 65
  • 130
3
votes
0 answers

About encoded proplems between python and C++

I use python3.8 and C++, G++ for C++. If I write Chinese(in Unicode) string in C++ program, It will show me wrong string when I run the program,like this: #include using namespace std; int main() { cout << "你好" << endl; return…
Simpid
  • 31
  • 1
  • 6
3
votes
1 answer

Incorrect parse with BCBio's GFF parser

I'm experimenting with BCBio's GFF parser, in the hope I can use it for my tool. I've taken a test .gbk file from NCBI's RefSeq database, and used it to parse into a .gff file. Code I used (from…
2
votes
1 answer

How does computer display a character on the screen with the correct encoding?

I'm interested in the encoding of the character in the computer. When I open my xxx.c with visual studio code, how does the VS code detect the encoding of my file and interprets these "01" sequence. Further on, how the visual studio code (or even…
jack chan
  • 21
  • 1
  • 6
2
votes
2 answers

Encode a string to gbk in Python

I am trying to see what different strings would look like in different encodings... For example: >>> str1 = "asdf" >>> str1.encode('utf-16') '\xff\xfea\x00s\x00d\x00f\x00' >>> str1.encode('base64') 'YXNkZg==\n' And those all get me what I want. But…
jCuga
  • 1,523
  • 3
  • 16
  • 28
2
votes
0 answers

How can I retrieve a record with Chinese characters in Java programming?

I got a problem for retrieving a record with Chinese characters in Java. Here is my code: EntityManagerFactory emfactory = Persistence.createEntityManagerFactory( "Eclipselink_JPA" ); EntityManager entitymanager =…
Kenny
  • 21
  • 1
2
votes
2 answers

How to config spring boot application to support both UTF-8 and GBK encode?

I am using spring boot in my project and I run some encoding issue. In the project, there is a controller(below) which accept request with a content type header ,"application/x-www-form-urlencoded;charset=GBK". @RequestMapping(value =…
NikoTung
  • 101
  • 1
  • 1
  • 10
2
votes
1 answer

GBK Encode/Decode Charset

I am receiving a binary packet from a server containing the following: var data = new Uint8Array([0xB2, 0xE2, 0xCA, 0xD4, 0x74, 0x65, 0x73, 0x74, 0x31, 0x32, 0x33]); I know it's a GBK charset and I am using the TextDecoder/TextEncoder API to read…
Vincent Thibault
  • 601
  • 5
  • 16
2
votes
5 answers

Convert GBK to utf8 string in python

I have a string. s = u"" How can I translate s into a utf-8 string? I have tried…
amazingjxq
  • 4,487
  • 7
  • 33
  • 35
1
vote
1 answer

Python3 ZipFile how to write non-utf8 filename to archive by using writestr function

I am writing something like auto-compress files and upload to server, and I'm using writestr to directly write bytes to ZipFile from memory. But for historical problems, I need to make it display properly on some Windows PC with GBK…
Notealot
  • 23
  • 5
1
vote
1 answer

A bug when using jemdoc+mathjax

I am using jemdoc+mathjax(http://www.mit.edu/~wsshin/jemdoc+mathjax.html) to make my website. However, when I am compiling, I came with the following mistake. If I want to simply compile jemdoc.py home, then everything goes ok. However, when I want…
bc a
  • 13
  • 2
1
vote
1 answer

how to start a for loop from a chosen row of pandas.df?

when processing a pandas.df with for loop.I usually meet up with errors. When the error has been removed, I will have to restart the for loop form the beginning of the dataframe. How can I start the for loop from the error position, getting rid of…
Helix Herry
  • 327
  • 1
  • 4
  • 14
1
vote
1 answer

Why R & Studio in Mac cannot import RData with Chinese content (created in win10)

I have been chasing this issue for all day long. I downloaded exercise materials for a text book via: http://www.crup.com.cn/UploadFiles/jxkj/gsgl/243184/统计学基于R第二版例题和习题数据.rar However, these RData work well in R & Rstudio in win10, while cannot show…
kangcheng
  • 13
  • 3
1
2 3 4