作者primochen (primo)
看板mud
标题Re: [闲聊] coffeemud
时间Mon Dec 12 22:05:24 2016
※ 引述《gasbomb (胖丁)》之铭言:
: http://www.coffeemud.org/
: 前面讨论串有人提到这个,在JAVA底下跑的mud
: 刚刚抓下来试了一下,使用上实在非常便利
: windows底下只要会double click就跑得起来了! XD
: 然後这引擎也提供了很多方便的工具
: 内建的东西套一套五分钟就有一个无脑打怪的迷宫可以玩了
: 不过好像没办法支援utf-8跟big-5的样子 :(
: 想改也不知从何改起,真是可惜了功能这麽强的软体阿
: -
: 要是对中文的支援性搞定了
: 说不定可以看到新站一直开站一直倒站的场景...!?
回这麽久以前的文章 真不好意思
最近才发现这个好东西
至少目前在 github上面的版本 utf-8支援的还不错
只要稍微改几个地方 如下
输出都是UTF-8
coffeemud.ini
# CHARSETINPUT is the name of the Java Character set to use for the default
# input stream. Default is iso-8859-1
#CHARSETINPUT=iso-8859-1
CHARSETINPUT=utf-8
# CHARSETOUTPUT is the name of the Java Character set to use for the default
# output stream. Default is iso-8859-1
#CHARSETOUTPUT=iso-8859-1
CHARSETOUTPUT=utf-8
Backend.java 这个是改内定DB 如果改用mysql等 就不用了
他在处理UTF-8时候 有bug 整个忽略了
else
{
// int val = 0;
// for (int i = 0; i < 4; i++)
// {
// c = (char) (fileBuffer[++dex[0]] & 0xFF);
// if (c >= 'A')
// val = (16 * val) + (c - 'A');
// else
// val = (16 * val) + (c - '0');
// }
String utf8 = "\\u";
for (int i = 0; i < 4; i++)
{
utf8 += (char) (fileBuffer[++dex[0]] & 0xFF);
}
buffer.append(decode(utf8));
static final String decode(final String in)
{
String working = in;
int index;
index = working.indexOf("\\u");
while(index > -1)
{
int length = working.length();
if(index > (length-6))break;
int numStart = index + 2;
int numFinish = numStart + 4;
String substring = working.substring(numStart, numFinish);
int number = Integer.parseInt(substring,16);
String stringStart = working.substring(0, index);
String stringEnd = working.substring(numFinish);
working = stringStart + ((char)number) + stringEnd;
index = working.indexOf("\\u");
}
return working;
}
所有的 cmvp样板档 这样编辑器也可以正常看到中文
<META HTTP-EQUIV="Pragma" CONTENT="no-cache" charset="UTF-8">
<---charset="UTF-8"
Siplet.java
有两个地方 这个改完 连网页连线都支援中文了
//in[0] = new BufferedReader(new InputStreamReader(sock.getInputStream(),
"iso-8859-1"));
in[0] = new BufferedReader(new InputStreamReader(sock.getInputStream(),
"UTF-8"));
--
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 182.235.41.126
※ 文章网址: https://webptt.com/cn.aspx?n=bbs/mud/M.1481551526.A.6ED.html
※ 编辑: primochen (182.235.41.126), 12/12/2016 22:10:18
※ 编辑: primochen (182.235.41.126), 12/12/2016 22:12:36
※ 编辑: primochen (182.235.41.126), 12/12/2016 22:16:37
1F:推 astroodie : 推荐python的Evennia, 支援unicode 35.10.222.212 12/13 00:07
3F:→ primochen : Evennia web client用webscoket 182.235.41.126 12/13 00:40
4F:→ primochen : 好先进 有空来看看 182.235.41.126 12/13 00:44
5F:推 typers : fluffos 也有支援 websocket / utf8 111.82.90.231 12/13 20:30
8F:推 dontpkme : 推个 1.160.92.121 01/22 13:07