P4.Net and P4CHARSET

余生颓废 提交于 2019-12-01 22:48:28

Have you tried nuking P4CHARSET and P4COMMANDCHARSET from your registry settings? They should be at HKEY_CURRENT_USER.Software.Perforce.Environment. I've been in a situation similar to yours before and that's how I ended up fixing it.

Also, are you using P4Win or P4V? I'm not entirely sure about P4V, but I know P4Win seemed to store charset information per connection. Maybe that could be interfering with P4.NET somehow?

UPDATE

The C++ API was detecting a Unicode charset because the P4CHARSET was set to none. Running p4 set P4CHARSET= from the command line fixed the issue for the poster.

I think the problem is the following code in 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() );
 }

because getClientApi()->GetCharset().Length() is non-zero for non-unicode servers also, ie. P4CHARSET is "none".

if I set the translation using getClientApi()->SetTrans(0, 0, 0, 0); where 0 is CharSetApi::CharSet::NOCONV it works.

i guess i'll have to use modified source. that sucks.

does anyone have a better way to do this?

Set p4.Charset to "iso8859-1" or some other charset.

If you're connecting to a non-unicode server, you shouldn't set p4.Charset at all. If you're making a client that needs to connect to both unicode, and non-unicode enabled servers, then I think you can set Charset to an empty-string for non-unicode, and one of the valid charsets otherwise.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!