Bad decoding for languages other than English
See original GitHub issueHi!
In line 767
, var buf = client.inbound.toString('binary', 0, MAX_CONTROL_LINE_SIZE);
encoding error will occur when using other languages.
I tried change 'binary'
to 'utf8'
in line 767
and add a function getting binary length from utf8 string:
function byteLength(str) {
// returns the byte length of an utf8 string
var s = str.length;
for (var i=str.length-1; i>=0; i--) {
var code = str.charCodeAt(i);
if (code > 0x7f && code <= 0x7ff) s++;
else if (code > 0x7ff && code <= 0xffff) s+=2;
if (code >= 0xDC00 && code <= 0xDFFF) i--; //trail surrogate
}
return s;
}
Then change line 936
var psize = m[0].length;
to var psize = byteLength(m[0])
, my problem seems solved.
Issue Analytics
- State:
- Created 6 years ago
- Comments:13 (7 by maintainers)
Top Results From Across the Web
Is English a dyslexic language? - PubMed
Increasingly, lack of orthographic transparency in English is seen as having a powerful negative effect on the development of reading skills in English-speaking ......
Read more >Misunderstood Minds . Reading Difficulties - PBS
Although, problems may occur in any area, decoding, comprehension, or retention, the root of most reading problems, in the view of many experts,...
Read more >Common Types of Reading Problems and How to Help ...
Consider whether fluency problems involve 1) poor decoding, ... Fluency may be weak due to language limitations (not poor decoding).
Read more >Language and Decoding Skills in Greek-English Primary ...
Research has shown that bilingual children tend to have relatively strong decoding skills but can lag behind monolinguals in linguistic ...
Read more >What Causes Decoding Difficulties in Beginning Readers, and ...
What is a Decoding Difficulty? · A child can only decode texts with greater than 90% accuracy when the texts are significantly below...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@Cyperwu Thanks for the report. Could you be so kind as to send us a sample input (subject) and payload that we can take a look at? Thanks!
v2 doesn’t deal with any encoding messages are simply byte arrays.