我们尝试在Windows上使用Java和UTF-8.应用程序在控制台上写入日志,我们希望将UTF-8用于日志,因为我们的应用程序具有国际化日志.
可以配置JVM,使其-Dfile.encoding=UTF-8作为JVM的参数生成UTF-8 .它工作正常,但Windows控制台上的输出是乱码.
然后,我们可以将控制台的代码页设置为65001(chcp 65001),但在这种情况下,.bat文件不起作用.这意味着当我们尝试通过我们的脚本(名为start.bat)启动我们的应用程序时,绝对没有任何反应.命令simple返回:
C:\Application> chcp 65001
Activated code page: 65001
C:\Application> start.bat
C:\Application>
Run Code Online (Sandbox Code Playgroud)
但没有chcp 65001,没有问题,应用程序可以启动.
有关于此的任何提示?
我试图将一个haskell示例(我之前遇到过)转换为scalaz.最初的例子如下:
("Answer to the ", (*)) <*> ("Ultimate Question of ", 6) <*> ("Life, the Universe, and Everything", 7)
Run Code Online (Sandbox Code Playgroud)
据我所知,使用此实例.
它没有按字面意思转换为scalaz:
scala> ("Answer to the ", ((_: Int) * (_: Int)) curried) |@| ("Ultimate Question of ", 6) |@| ("Life, the Universe, and Everything", 7) tupled
res37: (java.lang.String, (Int => (Int => Int), Int, Int)) = (Answer to the Ultimate Question of Life, the Universe, and Everything,(<function1>,6,7))
Run Code Online (Sandbox Code Playgroud)
虽然,我已经找了一个实例,它似乎在那里(再次,据我所知).
所以,问题是:为什么它不能像这样工作?或者我错过了什么/没有得到正确的答案?
我想删除BTreeMap通过迭代找到的项目.
由于在迭代时无法删除项目,因此我将要删除的项目放入向量中.主要问题是不可能使用引用向量,而只能使用值向量.必须克隆必须删除条目的所有密钥(假设密钥实现了Clone特征).
例如,这个简短的示例不编译:
use std::collections::BTreeMap;
pub fn clean() {
let mut map = BTreeMap::<String, i32>::new();
let mut to_delete = Vec::new();
{
for (k, v) in map.iter() {
if *v > 10 {
to_delete.push(k);
}
}
}
for k in to_delete.drain(..) {
map.remove(k);
}
}
fn main() {}
Run Code Online (Sandbox Code Playgroud)
它在编译时会产生以下错误:
error[E0502]: cannot borrow `map` as mutable because it is also borrowed as immutable
--> src/main.rs:17:9
|
9 | for (k, v) in map.iter() {
| --- …Run Code Online (Sandbox Code Playgroud) 我正在使用Eclipse 3.4的Google Application Engine插件,我在我的项目中添加了单元测试.单元测试位于名为source的源文件夹中tests,与源文件夹分开src.但是,在生成的war/classes中,测试类存在.
反正是不是将测试类放在生成的war/classes目录中?
谢谢.
java eclipse google-app-engine unit-testing google-eclipse-plugin
我试图使用一个具有函数的特征,该函数将闭包作为参数,然后在特征对象上使用它.
trait A {
fn f<P>(&self, p: P) where P: Fn() -> ();
}
struct B {
a: Box<A>
}
impl B {
fn c(&self) {
self.a.f(|| {});
}
}
Run Code Online (Sandbox Code Playgroud)
此代码段会生成以下错误:
the trait `A` is not implemented for the type `A` [E0277]
Run Code Online (Sandbox Code Playgroud)
版本rustc是rustc 1.0.0-beta.3 (5241bf9c3 2015-04-25) (built 2015-04-25).
我想改变
function (x:xs) = unwords (map reverse (words (x:xs)))
Run Code Online (Sandbox Code Playgroud)
进入点自由风格,我不能这样做.
不是简单的
function = unwords . map . reverse . words
Run Code Online (Sandbox Code Playgroud)
请帮我改变这点自由风格.
我在下面的命令行后尝试使用pointfree
cabal install pointfree
Run Code Online (Sandbox Code Playgroud)
编译和安装的所有内容,但是当我在终端中键入pointfree时,它一直在说没有这样的东西.