469,271 Members | 1,141 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,271 developers. It's quick & easy.

is there a UUDecode function available in JavaScript?

Does anyone know if there is a UUDecode function available to JavaScript

john
Sep 7 '12 #1
2 6192
gits
5,390 Expert Mod 4TB
there is a implementation https://github.com/kvz/phpjs/blob/ma...rt_uudecode.js for example. there is no built in method - but by searching the web you might find more implementations for it.
Sep 7 '12 #2
code from the above link not work properly. able to get code from some other location and the perfect work code is as follows

Expand|Select|Wrap|Line Numbers
  1. function decode64(input) {
  2.  
  3.     var keyStr = "ABCDEFGHIJKLMNOP" +
  4.     "QRSTUVWXYZabcdef" +
  5.     "ghijklmnopqrstuv" +
  6.     "wxyz0123456789+/" +
  7.     "=";
  8.  
  9.     var output = "";
  10.  
  11.     var chr1, chr2, chr3 = "";
  12.  
  13.     var enc1, enc2, enc3, enc4 = "";
  14.  
  15.     var i = 0;
  16.  
  17.     // remove all characters that are not A-Z, a-z, 0-9, +, /, or =
  18.  
  19.     var base64test = /[^A-Za-z0-9\+\/\=]/g;
  20.  
  21.     if (base64test.exec(input)) {
  22.  
  23.         alert("There were invalid base64 characters in the input text.\n" +
  24.  
  25.         "Valid base64 characters are A-Z, a-z, 0-9, '+', '/',and '='\n" +
  26.  
  27.         "Expect errors in decoding.");
  28.  
  29.     }
  30.  
  31.     input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");
  32.  
  33.     do {
  34.  
  35.         enc1 = keyStr.indexOf(input.charAt(i++));
  36.  
  37.         enc2 = keyStr.indexOf(input.charAt(i++));
  38.  
  39.         enc3 = keyStr.indexOf(input.charAt(i++));
  40.  
  41.         enc4 = keyStr.indexOf(input.charAt(i++));
  42.  
  43.         chr1 = (enc1 << 2) | (enc2 >> 4);
  44.  
  45.         chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
  46.  
  47.         chr3 = ((enc3 & 3) << 6) | enc4;
  48.  
  49.         output = output + String.fromCharCode(chr1);
  50.  
  51.         if (enc3 != 64) {
  52.  
  53.             output = output + String.fromCharCode(chr2);
  54.  
  55.         }
  56.  
  57.         if (enc4 != 64) {
  58.  
  59.             output = output + String.fromCharCode(chr3);
  60.  
  61.         }
  62.  
  63.         chr1 = chr2 = chr3 = "";
  64.  
  65.         enc1 = enc2 = enc3 = enc4 = "";
  66.  
  67.  
  68.  
  69.     } while (i < input.length);
  70.  
  71.  
  72.     return decodeURI(output);
  73.  
  74. }
Sep 13 '12 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

6 posts views Thread by Cathryn Lindner | last post: by
4 posts views Thread by Matt | last post: by
4 posts views Thread by Steven | last post: by
3 posts views Thread by Tanmaya Kulkarni | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.