sclass UTF8Processor { byte[] buffer = new byte[5]; int count = 0; S processByte(byte nextByte) ctex { buffer[count++] = nextByte; if(count == expectedBytes()) { S result = new S(buffer, 0, count, "UTF-8"); count = 0; return result; } return ""; } int expectedBytes() { int num = buffer[0] & 255; if(num < 0x80) return 1; if(num < 0xe0) return 2; if(num < 0xf0) return 3; if(num < 0xf8) return 4; return 5; } }
download show line numbers debug dex old transpilations
Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ekrmjmnbrukm, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1008076 |
Snippet name: | UTF8Processor - read an UTF-8 stream char by char |
Eternal ID of this version: | #1008076/2 |
Text MD5: | 8ba20377624bfc731e1503430bb3d864 |
Author: | stefan |
Category: | javax / gui |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2017-04-23 16:27:22 |
Source code size: | 510 bytes / 23 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 577 / 1524 |
Version history: | 1 change(s) |
Referenced in: | [show references] |