Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
x/text: Problem with charset 'hz-gb-2312', program stuck in infinite loop and gets killed! #35118
What version of Go are you using (
Not sure if this is going to help in tracking down the issue or not but have a look at the following tests (just changing the value of
So it's not the odd number of tildes that's breaking it either, hope this helps!
In that last case, shouldn't the decoder return an error? Since
The simplifiedchinese transformer seems to be returning
Hi, I would like to give this one a shot.
As mentioned, in this encoding '~' is an escape character which must be followed by another character, from RFC 1843:
As far as I can tell, Transform() only returns
The reason for the infinite loop is when the replacement character is inserted, the
The reason for the different behaviour on the number of '~' characters is due to the size of the destination buffer. If this buffer is not big enough to store the replacement character, Transform() returns
For example, byte("~~~~~") requires 5 bytes for the destination buffer (1 byte each for the 2 pairs of '~' + 3 bytes for the replacement character).
So to summarise behaviour
Perhaps an additional improvement in String() would be a sanity check if