question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Bad decoding for languages other than English

See original GitHub issue

Hi!

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:closed
  • Created 6 years ago
  • Comments:13 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
aricartcommented, Oct 18, 2017

@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!

0reactions
aricartcommented, Feb 8, 2021

v2 doesn’t deal with any encoding messages are simply byte arrays.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found