diff --git a/org/bbs_gbk_utf8.org b/org/bbs_gbk_utf8.org new file mode 100644 index 0000000..599cb12 --- /dev/null +++ b/org/bbs_gbk_utf8.org @@ -0,0 +1,82 @@ +#+TITLE: 支线任务: 中文 BBS GBK 转 UTF8 +#+DESCRIPTION: 造轮子好玩 +#+DATE: <2023-01-27 五> + +我过年这两天在服务器运维群看到了 水木清华BBS 这个东西, +于是就 telnet 试了下, 发现字符集是 GBK! +emmm, 设置环境变量启动终端不行, 就得在 gnome-terminal 设置里面弄. + +进去看了, 发现好多神奇的东西, 但整体还是没落, 现在还是虎年的欢迎页面... +接合我之前在 sdf.org, 新黑客词典, youtube 等地方看到的关于 BBS 的记忆片段, +使我开始考古这个从曾经那个时代来的我从没接触过的东西. + +先解决客户端问题: +我在 Back To BBS 节目里面看到了 [[https://syncterm.bbsdev.net][Syncterm]] 和 [[http://www.mysticbbs.com/downloads.html][Netrunner]], +一个不支持中文, 一个根本无法启动 (cannot open display). +然后我找到了 qterm, 先是在水木 FreeBSD 版块看见的, 后来搜索 BBS 客户端时想起来了. +下下来试一下, 不错. 但是我不想为了这一个东西而装一个额外软件, 还得编译. + +然后就想, 如果不能终端解码, 那为啥不先转换成 UTF8 再显示呢? +那就 iconv? 结果人家是全输入完 EOF 了才显示... +有没有方式能不缓冲而是 on-the-fly 呢? 搜索引擎没搜到. + +那就自己写! +iconv 是基于 libiconv 库, 看看文档就能写了, 虽然我基本没写过 C 代码. +#+BEGIN_SRC c +#include +#include + +#define UTF8_SIZE 4 + +int +convert_one(iconv_t cd) +{ + char inbuf[2] = {0}; + char outbuf[UTF8_SIZE] = {0}; + size_t insize = 1; + size_t outsize = UTF8_SIZE; + + char c = getchar(); + if (c == EOF) + return 1; + inbuf[0] = c; + + char * pIn = inbuf; + char * pOut = (char*) outbuf; + + size_t iconv_result = iconv(cd, &pIn, &insize, &pOut, &outsize); + if (iconv_result == (size_t) -1) { + inbuf[1] = getchar(); + insize = 2; + iconv(cd, &pIn, &insize, &pOut, &outsize); + } + + for (int i = 0; i < UTF8_SIZE; i++) { + if (outbuf[i] != 0) + putchar(outbuf[i]); + fflush(stdout); + } + return 0; +} + +int +main(void) +{ + iconv_t cd = iconv_open("UTF8", "GBK"); + while (1) + if (convert_one(cd) == 1) break; + + iconv_close(cd); + return 0; +} +#+END_SRC + +好使, 但是, 我写这篇文章的时候又过去看了眼那个帖子的回复, 发现有这个: +#+BEGIN_EXAMPLE +luit -encoding gbk +#+END_EXAMPLE +嗯, 好使... +另一个帖子说 GNU screen 也可以, +然后搜索 screen 转码的时候看到了这个 [[https://wadarochi.github.io/2011/05/24/GNU-screen-encoding的替代品,自制BBS转码脚本/][GNU screen encoding的替代品,自制BBS转码脚本]] + +*但自己造轮子还是很开心哈哈* diff --git a/org/cheatsheet.org b/org/cheatsheet.org index ce1ed02..4a59f55 100644 --- a/org/cheatsheet.org +++ b/org/cheatsheet.org @@ -19,18 +19,20 @@ | "{register}y/p | 向/从寄存器拷贝 | ** movement -| key | usage | -|----------+----------------------------| -| w/e | 下一个单词/单词尾 | -| b | 单词头 | +| key | usage | +|----------+------------------------| +| w/e | 下一个单词/单词尾 | +| b | 单词头 | | H/M/L | 当前页面可见顶部/中间/底部 | -| C-u(f)/d | 上/下翻页 | -| % | 到对应括号 | -| {} | 段落跳转 | -| g ; | goto last change | -| g */# | 正/反查找光标下的词 | -| g d/D | 跳转到本地/全局定义 | -| C-w | jump between splits | +| C-u(f)/d | 上/下翻页 | +| % | 到对应括号 | +| {} | 段落跳转 | +| g ; | goto last change | +| g */# | 正/反查找光标下的词 | +| g d/D | 跳转到本地/全局定义 | +| C-w | jump between splits | +| C-o/i | Older/Newer position | +| ` | mark | ** file/split | key | usage | diff --git a/org/internet_collections.org b/org/internet_collections.org index 848d488..5a59cff 100644 --- a/org/internet_collections.org +++ b/org/internet_collections.org @@ -2,6 +2,7 @@ #+TAGS: lowlevel(w) frontend(f) backend(b) algorithm(a) math(t) #+TAGS: hack(h) fun(u) wow(O) #+TAGS: emacs(m) linux(x) iot(i) plan9(9) BSD(B) +#+TAGS: smth #+OPTIONS: toc:1 ^:{} #+TITLE: Internet Collections @@ -13,13 +14,19 @@ /--\ \_ (/_ | |_ (_| | | | | | (_| (_| | (_ (_| | _|_ | | (_| (/_ >< _| #+END_SRC + +#+BEGIN_QUOTE +这才是互联网好玩的地方, 你总能在某个奇怪的角落发现神奇的东西 +-- 我 +#+END_QUOTE + * (Personal) Blogs :PROPERTIES: :CUSTOM_ID: blog :END: #+TAGS: rssable(s) rssub(U) gopher(g) ** Random Stuff Floating Around -not related to the root blog entry (I don't know what I mean) +not related to the root blog entry (I don't know what I mean, do you?) *** [[https://www.luogu.com.cn/blog/ivystorm/emacs-adventuredunnet-tong-guan-jiao-cheng][luogu blog: emacs dunnet 教程]] :emacs: *** [[https://bheisler.github.io/post/state-of-gpgpu-in-rust/][The State of GPGPU in Rust]] :rust:lowlevel: *** [[https://secretgeek.github.io/html_wysiwyg/][巧用 CSS 显示 HTML 源码]] :frontend: @@ -234,8 +241,10 @@ int function(void) { ** [[https://ifaceless.github.io/2019/11/17/guide-to-linux-scheduler/][论文学习之 Linux 调度器]] *** [[https://ifaceless.github.io/2019/10/30/linux-kernel-dev-notes/][Linux Kernel Development 学习与总结]] ** [[https://hardenedlinux.github.io][Hardened GNU/Linux]] :hack: +** TODO [[https://briancallahan.net][Dr. Brian Robert Callahan]] :BSD: +*** [[https://briancallahan.net/blog/20220629.html][OpenBSD has two new C compilers: chibicc and kefir]] :smth: -** B +** B/HWS/fri3nds *** [[https://shakaianee.top/][社会易姐]] *** [[https://blog.yangmame.org/][yanemame]] 猴哥推荐的 @@ -251,14 +260,22 @@ EvanMeek / B站: 美味的樱桃菌 **** [[https://sh.alynx.one/posts/Linux-Mooncake-Jokes/][Linux 用户的月饼食用手册]] :fun: **** [[https://sh.alynx.one/posts/Do-Not-Fill-My-Email-with-Silly-Ads/][不要拿愚蠢的广告来污染我的邮箱]] **** [[https://sh.alynx.one/posts/Emacs-Monaco-Box-drawing-Character/][Emacs 和 Monaco 字体和 Box-drawing Character]] +*** [[http://www.z.org.cn/][老网虫]] +*** [[https://blog.yang-qwq.ml][yang-qwq]] +*** [[http://blog.zhanganzhi.com/][zhanganzhi]] +*** [[https://blog.bluemangoo.net/][芒果快评]] +今年的新博客, 友链有踏浪 +*** [[https://acyanbird.github.io][山奈]] + ** ZhiHu *** [[https://zhuanlan.zhihu.com/p/138719668][用Go语言汇编计算fibonacci数列]] :lowlevel: *** [[https://www.cnblogs.com/zjjws/p/13346020.html][第 N 个质数]] :c:algorithm: 看不懂, 先收藏着 *** [[https://www.zhihu.com/column/c_1313110231912726528][倔强的程序员]] 编! 译! 原! 理! -*** [[https://www.zhihu.com/column/c_185117725][专栏: 技术考古]] :plan9: -plan9 +*** [[https://www.zhihu.com/column/c_185117725][专栏: 技术考古]] :wow:plan9: +**** [[https://web.archive.org/web/20220423091317/https://zhuanlan.zhihu.com/p/502733643][archive: 那些古老又优美的 GUI]] :smth: +***** [[https://guidebookgallery.org][GUI Gallery]] *** [[https://www.zhihu.com/column/roartalk][专栏: 嘶吼RoarTalk]] :hack: 回归最本质的信息安全 *** [[https://zhuanlan.zhihu.com/p/464565089][我抵制Notepad++的理由]] @@ -279,12 +296,6 @@ use the power of tor: *** [[https://www.zhihu.com/question/306745383][ubuntu重启变成了debian怎么办?]] U boom tu -** shenjack/HWS/fri3nds -*** [[http://www.z.org.cn/][老网虫]] -*** [[https://blog.yang-qwq.ml][yang-qwq]] -*** [[http://blog.zhanganzhi.com/][zhanganzhi]] -*** [[https://blog.bluemangoo.net/][芒果快评]] -今年的新博客, 友链有踏浪 * YouTube (没有账号, 这就是我的收藏夹) :PROPERTIES: @@ -404,11 +415,12 @@ to filing patently fraudulent DMCA counter-notifications to avoid the terminatio **** [[https://youtu.be/2CnAzLB0OjU][DT: As The Web Grows Bigger, It Seems Smaller]] *** [[https://youtu.be/Rsxao9ptdmI][Beating 5 Scam Arcade Games with Science]] 街机科学家~ -*** [[https://youtube.com/playlist?list=PLgE-9Sxs2IBVgJkY-1ZMj0tIFxsJ-vOkv][BBS The Documentary(8)]] *** [[https://youtu.be/k35uDHs7Z9E][DT: A Disturbing Descent Into The Mind Of A Mad Man]] *** [[https://youtu.be/GlovVvBAIGk][DT: Keeping A Positive Attitude Even After Storm Destroys My Backyard]] *** [[https://www.youtube.com/@lecturesbywalterlewin.they9259][Lectures by Walter Lewin. They will make you ♥ Physics]] :wow: *** [[https://youtu.be/dIivJwz5jL8][Nyan Cat piano arrangement sight-read by Tom Brier]] +*** [[https://www.youtube.com/playlist?list=PLop3s1hMlSJKXqmuFjK7gbJh2WAyllTTY][Back to the BBS]] +**** [[https://www.erb.pw][homepage]] * r :PROPERTIES: @@ -441,6 +453,8 @@ to filing patently fraudulent DMCA counter-notifications to avoid the terminatio Huwawei NB! ** [[https://lkml.org/lkml/2007/7/27/426][Linus re SD]] ** [[https://marc.info/?l=openbsd-tech&m=167374666324119&w=2][openbsd-tech: xonly on amd64: testing wanted]] +** [[https://lists.freebsd.org/pipermail/freebsd-current/2003-July/006889.html][freebsd : Annoucning DragonFly BSD!]] +** [[https://minnie.tuhs.org/pipermail/tuhs/2022-April/025643.html][TUHS: Sad News - we last two wonderful people in the past few weeks]] * Other :PROPERTIES: diff --git a/org/whatif_openbsd.org b/org/whatif_openbsd.org index 200c113..1d61af5 100644 --- a/org/whatif_openbsd.org +++ b/org/whatif_openbsd.org @@ -109,6 +109,7 @@ grub> boot 然后就是安装一堆软件 我没有安装那些 "现代化 UNIX 工具", 比如 htop bat exa zoxide, (ripgrep 除外, 太好用了) +7z 真的好用, 但是我觉得更应该学学标准的 UNIX 压缩解压工具 #+BEGIN_SRC ksh doas pkg_add firefox neovim git pcmanfm noto-cjk # 特别必要的 doas pkg_add ripgrep fzf ncdu neofetch ranger p7zip colortree # 好用的工具 @@ -313,7 +314,9 @@ iwx0 at pci0 dev 20 function 3 "Intel Wi-Fi 6 AX201" rev 0x20, msix :CUSTOM_ID: btrfs :END: -我有时候会想访问 Linux 上的文件, 但是似乎不支持 btrfs... +我有时候会想访问 Linux 上的文件, 但是似乎不支持 btrfs...[fn:13] + +** [[https://dongdigua.github.io/bbs_gbk_utf8][支线任务: 中文 BBS GBK 转 UTF8]] * Footnotes @@ -333,6 +336,7 @@ iwx0 at pci0 dev 20 function 3 "Intel Wi-Fi 6 AX201" rev 0x20, msix [fn:10] https://www.openbsd.org/faq/faq4.html#SendDmesg [fn:11] FAQ: dmesg archive https://www.mail-archive.com/misc@openbsd.org/msg162300.html [fn:12] NYC*BUG dmesgd https://dmesgd.nycbug.org/index.cgi +[fn:13] Accessing Other Filesystems https://www.openbsd.org/faq/faq14.html#foreignfs * Related Links :PROPERTIES: diff --git a/posts.md b/posts.md index 7971b2a..e69e2e1 100644 --- a/posts.md +++ b/posts.md @@ -1,5 +1,6 @@ ## Table of Contents ### Posts (sorted by time) +- [支线任务: 中文 BBS GBK 转 UTF8](bbs_gbk_utf8)
- [我要不要试试 OpenBSD](whatif_openbsd)
- [一个乐子 commit](lol.diff.txt)
- [一次大备份](backup_everything)