Giter Club home page Giter Club logo

Comments (7)

andris9 avatar andris9 commented on August 28, 2024

I think there's a gap in the docs about it – you should either use Uint8Array|ArrayBuffer or pseudo-binary string values for 8-bit values, not unicode strings. For example, you can use TextEncoder API to convert an unicode string to an Uint8Array:

var buf = new TextEncoder('utf-8').encode('õäöü');
// [0xC3, 0xB5, 0xC3, 0xA4, 0xC3, 0xB6, 0xC3, 0xBC]

from mailreader.

felixhammerl avatar felixhammerl commented on August 28, 2024

which is something we might as well fix in here? just put everything into a uint8array internally? wouldnt make a difference then for thomas...

from mailreader.

andris9 avatar andris9 commented on August 28, 2024

The pseudobinary input comes from browserbox, probably doesn't make sense to convert all output from strings to typed arrays and then back again when parsing.

from mailreader.

felixhammerl avatar felixhammerl commented on August 28, 2024

fair enough
On Mar 5, 2015 9:13 AM, "Andris Reinman" [email protected] wrote:

The pseudobinary input comes from browserbox, probably doesn't make sense
to convert all output from strings to typed arrays and then back again when
parsing.


Reply to this email directly or view it on GitHub
#12 (comment)
.

from mailreader.

andris9 avatar andris9 commented on August 28, 2024

Incoming data from TCPSocket to BrowserBox is an ArrayBuffer. BrowserBox converts this to pseudo-binary (can't use ascii (might include 8-bit data) or utf-8 (might be something else than utf-8)), does its stuff and passes it on as is. MimeParser on the other end receives the pseudo-binary stuff, detects the correct charset and outputs valid unicode strings. So all string data between TCPSocket input and MimeParser output (which also includes mailreader objects) is in pseudo-binary format by default to minimize conversions from one type to another.

from mailreader.

andris9 avatar andris9 commented on August 28, 2024

Just to be clear, pseudo-binary is what you get with this:

var str = unescape(encodeURIComponent('õäöü'));
// "õäöü"

it looks like a 8-bit string while actually it is an unicode string, that only uses the first 256 code points.

from mailreader.

toberndo avatar toberndo commented on August 28, 2024

Thanks for the quick response. I tried unescape(encodeURIComponent('õäöü')) with my test content, and yes that would lead to the correct result.

A little background on how we are currently using mailreader: the idea is to simply throw the output of https://github.com/openpgpjs/openpgpjs/blob/master/src/openpgp.js#L139 at mailreader.parse and get the MIME nodes as a result.

I did some more testing and the following works fine:

rawText = unescape(encodeURIComponent(rawText));
that.mailreader.parse([{raw: rawText}], function(parsed) {

from mailreader.

Related Issues (4)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.