4 ms·
> This only makes sense if your metric is number of code points. Not quite! :) I wrote a similar tool I called baseunicode[1]. (Glad I'm not the only one who's
by deathanatos 11y ago
> This only makes sense if your metric is number of code points.
Not quite! :) I wrote a similar tool I called baseunicode[1]. (Glad I'm not the only one who's discovered this!) The author here is using it for tweets (which oddly don't count bytes, they count code points); I wrote my version for copy/pasting data between terminals[2]: copying more than a screen's worth is a hassle, so "screen area" is the metric I'm trying to optimize, which ends up being subtly different from the article's, which is code points for a tweet. (for screen area in a terminal, some characters — CJK in particular — end up taking multiple columns; and combining code points (like acute accent) are basically free!)
In my case, it ended up being easier to use base64, because it's installed by default.
[2]: SCP is just a pain sometimes. If you need to read a file only privileged by root, AFAIK, it's out of luck. I'm usually going server-to-server, so I also need to remember to -3, which I inevitably forget. You can get around the root issue w/ `ssh source 'sudo cat /foo/bar' | ssh destination 'cat >foo', (or 'sudo bash -c "cat >foo" if you need root on the write…) but more work; often I find I'm already there in both terminals and I just want these bytes from this split in this other split, so I started doing `tar -cz <stuff> | base64`, copy, `base64 -d | tar -xz`, paste. And then screen size mattered, thus baseunicode.
[1]: https://github.com/thanatos/baseunicode https://github.com/thanatos/baseunicode
- amptorn 11y agoIf screen area is your metric, and combining code points are free, I bet you could use [1] to add an arbitrary amount of data to a single character. [1] http://www.eeemo.net/ http://www.eeemo.net/
- adimitrov 11y ago> which oddly don't count bytes, they count code points Not so odd, but very sensible! I'm always saddened by this oversight in SMS messages — they're 160 7bit characters, so 140 octets. But those 7bit characters are the GSM charset. If you want to write in other languages than Western European ones, your message will be encoded using UTF-16 — now you only have 70 characters. It might be OK for Chinese, but it's absolutely unusable for Cyrillic. Of course, the limiting factor in SMS is architectural, whereas in Twitter, it's philosophical, so there's your difference.
- Dylan16807 11y agoThere's only so many ways you can slice a kilobyte. Measuring bits is just the way to do it for data transmissions. Support for compact representation of more languages would have been nice. Something like an 8 bit mode with 2 byte escapes for setting code page and 3 byte escapes for arbitrary unicode characters. As a bonus you'd actually be able to fit more emoji in that mode, 46 vs. 35.
- colanderman 11y agoI do this too. xclip is your friend.