5

I'm using P4.Net to connect to my non-unicode server however some commands i run fail with:

              "Unicode clients require a unicode enabled server."

how do i change the P4CHARSET to none in P4.Net? I've tried

              P4Connection p4 = new P4Connection();
              p4.Charset = "none"
              p4.Connect()

i've also tried changing the Charset just before the p4.Run command:

              p4.Charset = "none"
              p4.Run("where", "c:\\some\\random\\dir");

i've tried setting the Charset to "none", null and "".

if i try passing global options to the p4.Run command it doesn't work either. ie.

              p4.Run("-C none where", "c:\\some\\random\\dir");

fails with "Unknown Command"

has anyone had any success with changing the P4CHARSET within a P4.Net script? how do you do it?

SLaks
  • 868,454
  • 176
  • 1,908
  • 1,964
randomfigure
  • 420
  • 5
  • 13

4 Answers4

2

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.

Mike O'Connor
  • 3,813
  • 24
  • 27
  • @Mike O'Connor Yes, i have tried removing those from my registry settings and also resetting them to `none` in the registry. din't work. i'm using P4V, but this problem only occurs on Win7 (the charset gets set to winansi even when i manage the it thru P4Win for the connection and 'Open Command Prompt Here'). I checked the P4.Net code in public.perforce.com - it appears that it doesn't contain support for newer servers (i'm on `Server version: P4D/LINUX26X86_64/2009.2/238357 (2010/03/15)`) which return `none` for no charset instead of an empty string. – randomfigure Mar 17 '11 at 16:54
  • @randomfigure Hmm. Do you happen to have a local server instance running on your box that you can test against? I'm running 2010.2 on Win7 x64 and I have no problems running P4.NET commands on that server. Maybe there's something going on with the Linux version, or maybe your P4.NET binaries are different than mine? – Mike O'Connor Mar 18 '11 at 00:03
  • 1
    @randomfigure Actually scratch that previous comment, the server version shouldn't matter at all. Have you tried running 'p4 set P4CHARSET=' from the command line? If that doesn't work then I'd probably resort to editing the client api code. – Mike O'Connor Mar 18 '11 at 01:56
  • @randomfigure Awesome, so using p4 set worked? If so I'll update my answer. – Mike O'Connor Mar 22 '11 at 05:24
  • @Mike O'Connor yes, using `p4 set P4CHARSET=` (in windows cmd) or `export P4CHARSET=` (in bash) works for my use case. Thanks for the suggestion. – randomfigure Mar 28 '11 at 19:24
1

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?

randomfigure
  • 420
  • 5
  • 13
0

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

SLaks
  • 868,454
  • 176
  • 1,908
  • 1,964
  • thanks for the response. unfortunately this doesn't help. i've tried all of the following:"Character set must be one of: none, utf8, utf8-bom, iso8859-1, shiftjis, eucjp, iso8859-15, iso8859-5, macosroman, winansi, koi8_r, cp1251, utf16, utf16-nobom, utf16le, utf16le-bom, utf16be, utf16be-bom, utf32, utf32-nobom, utf32le, utf32le-bom, utf32be, or utf32be-bom Check P4CHARSET and your '-C' option." – randomfigure Mar 09 '11 at 19:15
0

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.

Shawn
  • 1
  • I need only connect to a non-unicode server, however on newer servers than P4.Net apparently supports (i'm on `Server version: P4D/LINUX26X86_64/2009.2/238357 (2010/03/15)`) charset is set to `none` instead of an empty string. P4.Net only tests for empty string, not for `none` also (forward compatibility). – randomfigure Mar 17 '11 at 16:58