我正在使用P4.Net连接到我的非unicode服务器,但是我运行的一些命令会失败:
"Unicode clients require a unicode enabled server."如何在P4.Net中将P4CHARSET更改为none?我试过了
P4Connection p4 = new P4Connection();
p4.Charset = "none"
p4.Connect()我还尝试在p4.Run命令之前更改字符集:
p4.Charset = "none"
p4.Run("where", "c:\\some\\random\\dir");我已经尝试将字符集设置为"none“、null和"”。
如果我尝试将全局选项传递给p4.Run命令,它也不起作用。即。
p4.Run("-C none where", "c:\\some\\random\\dir");失败并显示"Unknown Command“
有没有人成功地在P4.Net脚本中更改了P4CHARSET?你是怎么做到的?
发布于 2011-03-17 06:49:44
你有没有试过从你的注册表设置中删除P4CHARSET和P4COMMANDCHARSET?他们应该在HKEY_CURRENT_USER.Software.Perforce.Environment.我以前遇到过和你类似的情况,这就是我最终解决它的原因。
另外,你使用的是P4Win还是P4V?我不完全确定P4V,但我知道P4Win似乎存储每个连接的字符集信息。也许这会以某种方式干扰P4.NET?
更新
由于P4CHARSET设置为none,C++ API正在检测Unicode字符集。从命令行运行p4 set P4CHARSET=修复了海报的问题。
发布于 2011-03-10 03:14:31
我认为问题出在ClientApi_m.cpp中的以下代码:
void p4dn::ClientApi::Init( p4dn::Error* e )
{
if(getClientApi()->GetCharset().Length() > 0)
{
// unicode server use UTF-8
_encoding = new System::Text::UTF8Encoding();
// set the translations (use UTF-8 for everything but content).
CharSetApi::CharSet content = CharSetApi::Lookup(getClientApi()->GetCharset().Text());
getClientApi()->SetTrans(CharSetApi::CharSet::UTF_8, content,
CharSetApi::CharSet::UTF_8, CharSetApi::CharSet::UTF_8);
}
else
{
// non-unicode server use ANSI encoding
_encoding = System::Text::Encoding::GetEncoding(1252);
}
getClientApi()->Init( e->get_InternalError() );
}因为对于非unicode服务器,getClientApi()->GetCharset().Length()也是非零的。P4CHARSET是"none"。
如果我使用getClientApi()->SetTrans(0, 0, 0, 0);设置转换,其中0为CharSetApi::CharSet::NOCONV,它可以工作。
我想我将不得不使用修改过的源码。这太糟糕了。
有没有人有更好的方法呢?
发布于 2011-03-09 09:54:13
将p4.Charset设置为"iso8859-1"或其他一些字符集。
https://stackoverflow.com/questions/5240500
复制相似问题