UTF8什么时候能开放啊?
现在这个GBK实在是太不方便了。北大侠客行MUD,中国最好的MUD 换行乱码如果不是gbk的问题的话,我觉得gbk没有什么不好啊... 回复 1# cohomology
貌似目前没有计划。之前jason弄过一个不完全的utf8,只能支持utf8输出、不支持utf8指令的那种,后来不了了之了,因为需求不是很大。 回复 3# hypnos
我自己用Haskell做了一个客户端,显示中文就是有问题,用luit也解决不了。
ps,我分析了一下输出,貌似里面有很多类似^[[31;42;0m^[[30;40;1m这样的ansi控制符,请问第一个控制符的作用在哪里?
#!/bin/bash
# This script echoes colors and codes
echo -e "\n\033[4;31mLight Colors\033[0m\t\t\033[1;4;31mDark Colors\033[0m"
echo -e "\e[0;30;47m Black \e[0m 0;30m \t\e[1;30;40m Dark Gray\e[0m 1;30m"
echo -e "\e[0;31;47m Red \e[0m 0;31m \t\e[1;31;40m Dark Red \e[0m 1;31m"
echo -e "\e[0;32;47m Green \e[0m 0;32m \t\e[1;32;40m Dark Green \e[0m 1;32m"
echo -e "\e[0;33;47m Brown \e[0m 0;33m \t\e[1;33;40m Yellow \e[0m 1;33m"
echo -e "\e[0;34;47m Blue \e[0m 0;34m \t\e[1;34;40m Dark Blue\e[0m 1;34m"
echo -e "\e[0;35;47m Magenta\e[0m 0;35m \t\e[1;35;40m DarkMagenta\e[0m 1;35m"
echo -e "\e[0;36;47m Cyan \e[0m 0;36m \t\e[1;36;40m Dark Cyan\e[0m 1;36m"
echo -e "\e
是对应的颜色编码吗?经常在写 bash 脚本的时候,要给输出文字上颜色,上面为几个颜色的代码对照
运行后就能看到效果 回复 5# redcoat
我知道这些东西是控制符
0是重置对吧?那像我举的例子里面连续两个控制符,第一个^[[31;42;0m不就多余了吗? 会不会是编码的片段
测试字体一^[[31;42;0m^[[30;40;1m测试字体二...
第一个控制符是属于前面字体的重置,类似北侠mud里的$NOR$, 由此开始第二个控制符,描述后面字体的颜色 本帖最后由 hypnos 于 2017-2-5 03:17 PM 编辑
不要问……自己当年写的自己已经看不懂了……虽然本来也是low到爆
# coding: utf-8
class Ansi
attr_accessor :Maps, :ESC
# Class variable
@@ESC = "\e"
@@Maps = {
# @@ESC = "\e",
#define @@ESC ""
#define CSI @@ESC + "["
# Foregroud
@@ESC + "[30m" => "BLK", # Black
@@ESC + "[31m" => "RED", # Red
@@ESC + "[32m" => "GRN", # Green
@@ESC + "[33m" => "YEL", # Yellow
@@ESC + "[34m" => "BLU", # Blue
@@ESC + "[0;34m" => "BLU", # Blue(pkuxkx)
@@ESC + "[35m" => "MAG", # Magenta
@@ESC + "[36m" => "CYN", # Cyan
@@ESC + "[0;36m" => "CYN", # Cyan(pkuxkx)
@@ESC + "[37m" => "WHT", # White
@@ESC + "[37;0m" => "WHT", # White(pkuxkx)
@@ESC + "[0;37m" => "WHT", # White(pkuxkx)
# Hi Intensity Foreground Colors
@@ESC + "[1;30m" => "灰", # 灰色?(pkuxkx)
@@ESC + "[1;31m" => "HIR", # Red
@@ESC + "[0;1;31m" => "HIR", # Red(pkuxkx)
@@ESC + "[1;32m" => "HIG", # Green
@@ESC + "[1;33m" => "HIY", # Yellow
@@ESC + "[1;34m" => "HIB", # Blue
@@ESC + "[1;35m" => "HIM", # Magenta
@@ESC + "[1;36m" => "HIC", # Cyan
@@ESC + "[1;37m" => "HIW", # White
# High Intensity Background Colors
@@ESC + "[41;1m" => "HBRED", # Red
@@ESC + "[42;1m" => "HBGRN", # Green
@@ESC + "[43;1m" => "HBYEL", # Yellow
@@ESC + "[44;1m" => "HBBLU", # Blue
@@ESC + "[45;1m" => "HBBLU", # Magenta
@@ESC + "[46;1m" => "HBCYN", # Cyan
@@ESC + "[47;1m" => "HBWHT", # White
#Background Colors
@@ESC + "[40m" => "BBLK", # Black
@@ESC + "[41m" => "BRED", # Red
@@ESC + "[42m" => "BGRN", # Green
@@ESC + "[43m" => "BYEL", # Yellow
@@ESC + "[44m" => "BBLU", # Blue
@@ESC + "[45m" => "BMAG", # Magenta
@@ESC + "[46m" => "BCYN", # Cyan
# @@ESC + "[47m" => "BWHT", # White
@@ESC + "[2;37;0m" => "NOR", # Puts everything back to normal
@@ESC + "[0m" => "",
@@ESC + "[1m" => "HI",
@@ESC + "[1A" + @@ESC + "[200D" + @@ESC + "[K" => "DES",
@@ESC + "[1;5m" => "BNK", # pkuxkx
@@ESC + "[7m" => "REV", #pkuxkx
@@ESC + "[4m" => "U", #pkuxkx
}
# Class method
def Ansi.colorprocess(str, colorful)
if colorful then
@@Maps.each { |k, v|
str.gsub!(k, "$" +v.to_s + "$")
}
else
@@Maps.each {|k,v|
str.gsub!(k, "")
}
end
return str
end
end
=begin
#颜色处理测试
ansi = Ansi.new
a = "\r\e[2;37;0m\e[1;37m【江湖】\e[36m杭州城\e[36m中有\e[37m毛头小贼\e[2;37;0m\e[1;37m\e[36m横行,据说此贼带有价值\e[1;33m尚可\e[2;37;0m\e[1;37m\e[36m的财宝!\e[2;37;0m\r\n"
a = " \e[44;1m∷∷\e[37;0m\r\n \e[44;1m∷∷\e[37;0m 个素未谋面,可借此头的?我喜欢偶尔在这个世界里出现, \e[44;1m∷∷\e[37;0m\r\n \e[44;1m∷∷\e[37;0m 因为在这里,我们也许欢笑一堂,也许睚眦必报,但是我们 \e[44;1m∷∷\e[37;0m\r\n \e[44;1m∷∷\e[37;0m 都没有那么虚伪,我们活得不累。娱乐存在的意义,不在于 \e[44;1m∷∷\e[37;0m\r\n \e[44;1m∷∷\e[37;0m 它给我欢乐,而在于它给了我空间,尽管这空间是虚拟的, \e[44;1m∷"
print a
puts Ansi.colorprocess(a, true)
a = "\r\e[2;37;0m\e[1;37m【江湖】\e[36m杭州城\e[36m中有\e[37m毛头小贼\e[2;37;0m\e[1;37m\e[36m横行,据说此贼带有价值\e[1;33m尚可\e[2;37;0m\e[1;37m\e[36m的财宝!\e[2;37;0m\r\n"
print a
puts Ansi.colorprocess(a, false)
=end
回复 8# hypnos
比如这里面的
\e[2;37;0m\e[1;37m\e[36m
和\e[1;36m最终效果是不是一样? 回复 9# cohomology
问这种问题有什么意义?
页:
[1]