1/* 2--- 3description: String UTF8 encoding. 4license: MIT-style 5authors: [Christopher Pitt] 6provides: [String.toUTF8] 7requires: 8 core/1.2.4: [String] 9... 10*/ 11 12(function() { 13 14 function utf8(string) 15 { 16 var a, b, result = '', 17 from = String.fromCharCode; 18 19 for (a = 0; b = string.charCodeAt(a); a++) 20 { 21 if (b < 128) 22 { 23 result += from(b); 24 } 25 else if ((b > 127) && (b < 2048)) 26 { 27 result += from((b >> 6) | 192); 28 result += from((b & 63) | 128); 29 } 30 else 31 { 32 result += from((b >> 12) | 224); 33 result += from(((b >> 6) & 63) | 128); 34 result += from((b & 63) | 128); 35 } 36 } 37 38 return result; 39 } 40 41 String.implement({ 42 'toUTF8': function() 43 { 44 return utf8(this); 45 } 46 }); 47 48})();
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.