由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Java版 - expression in unicode
相关主题
怎麼得到字符串中的raw bytes?一个加密解密的问题?
java问题:如何match两个正规表达式一道 JAVA Stack vs Heap 题
String newvalue = value.replaceAll("%"," ");问一个Java题
请帮忙看看这个编译错误Java练习题 3
这个怎么不对?java 的内存分布?
why doesn't replaceAll work?string pool vs class constant pool问题,在线等
Java大侠们:Hashtable help please!问个set和literal String的问题
TIJ上写错了?问个很简单的问题?
相关话题的讨论汇总
话题: string话题: u000a话题: unicode话题: expression话题: right
进入Java版参与讨论
1 (共1页)
s*****i
发帖数: 650
1
String b = "\u000A"; is syntax error.
String b = "\u0009"; is right,
String b = "\u001A"; is right too.
why?
How to input "\u000A" into a variable?
thx
o***e
发帖数: 30
2
"\n"
who cares why, it's very special case.
but there's one paragraph just to explain
this in the java spec if you want to know.

【在 s*****i 的大作中提到】
: String b = "\u000A"; is syntax error.
: String b = "\u0009"; is right,
: String b = "\u001A"; is right too.
: why?
: How to input "\u000A" into a variable?
: thx

s*****i
发帖数: 650
3
The problem is you can not input the unicode from
"\u000A"
"\u000B"
"\u000C"
"\u000D"
...

【在 o***e 的大作中提到】
: "\n"
: who cares why, it's very special case.
: but there's one paragraph just to explain
: this in the java spec if you want to know.

s*******d
发帖数: 4135
4
The answer is here:
http://java.sun.com/docs/books/jls/second_edition/html/lexical.doc.html#231571

【在 s*****i 的大作中提到】
: The problem is you can not input the unicode from
: "\u000A"
: "\u000B"
: "\u000C"
: "\u000D"
: ...

s*******d
发帖数: 4135
5
简单说一下
这一行程序:
String s = "\u000A";
java编译器会把它读为(分成2行):
String s = "
";
这样就出现了unclosed string literal的错误了.

【在 s*****i 的大作中提到】
: The problem is you can not input the unicode from
: "\u000A"
: "\u000B"
: "\u000C"
: "\u000D"
: ...

m******t
发帖数: 2416
6

If you need something you can generalize and put through a loop,
try this:
String s = new String(new byte[]{10});
Note that's a piece of what-the-hell-is-it-trying-to-do code though.
8-)

【在 s*****i 的大作中提到】
: The problem is you can not input the unicode from
: "\u000A"
: "\u000B"
: "\u000C"
: "\u000D"
: ...

1 (共1页)
进入Java版参与讨论
相关主题
问个很简单的问题?这个怎么不对?
help about bitstream writerwhy doesn't replaceAll work?
怎样吧byte[]变成java.security.Key?Java大侠们:Hashtable help please!
How to parse the bytes[]TIJ上写错了?
怎麼得到字符串中的raw bytes?一个加密解密的问题?
java问题:如何match两个正规表达式一道 JAVA Stack vs Heap 题
String newvalue = value.replaceAll("%"," ");问一个Java题
请帮忙看看这个编译错误Java练习题 3
相关话题的讨论汇总
话题: string话题: u000a话题: unicode话题: expression话题: right