Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 219135 Details for
Bug 385891
Faster implementation of base64 decoding.
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
improved base64 decoder
decode.txt (text/plain), 1.63 KB, created by
Mike Wilson
on 2012-07-24 16:36:12 EDT
(
hide
)
Description:
improved base64 decoder
Filename:
MIME Type:
Creator:
Mike Wilson
Created:
2012-07-24 16:36:12 EDT
Size:
1.63 KB
patch
obsolete
>function decodeBase64(input) { > > var seg1, seg2, seg3, seg4; > var output = ""; > > /* equivalent to > "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=" > .indexOf(input.charAt(index)) > */ > function decodeChar (input, index) { > var code = input.charCodeAt(index); > if (code === 43 /* '+' */) { return 62; } > if (code === 47 /* '/' */) { return 63; } > if (code === 61 /* '=' */) { return 64; } > if (code > 96 /* lowercase */) { return code - 71; } > if (code > 64 /* uppercase */) { return code - 65; } > return code + 4; /* numbers */ > } > > /* Emit 0..3 characters based on the encoded value. */ > function emitChars (c) { > if (c < 128) { > if (c === 10) { > return; /* Strip CR chars */ > } > output += String.fromCharCode(c); > } > else if(c < 2048) { > output += String.fromCharCode((c >> 6) | 192); > output += String.fromCharCode((c & 63) | 128); > } > else { > output += String.fromCharCode((c >> 12) | 224); > output += String.fromCharCode(((c >> 6) & 63) | 128); > output += String.fromCharCode((c & 63) | 128); > } > } > > /* Strip line breaks and any other bogus characters. */ > input = input.replace(/[^A-Za-z0-9\+\/\=]/g, ""); > if (input.length % 4 !== 0) { > throw "malformed base64"; > } > > for (var i = 0; i < input.length; ) { > seg1 = decodeChar(input, i++); > seg2 = decodeChar(input, i++); > seg3 = decodeChar(input, i++); > seg4 = decodeChar(input, i++); > > emitChars((seg1 << 2) | (seg2 >> 4)); > if (seg3 !== 64) { > emitChars(((seg2 & 15) << 4) | (seg3 >> 2)); > } > if (seg4 !== 64) { > emitChars(((seg3 & 3) << 6) | seg4); > } > } > > return output; >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 385891
:
219135
|
219154