[p4perl] Re: P4WEB and Unicode Servers
Tony Smith
tony@smee.org
Tue, 7 Dec 2004 16:52:28 +0000
Hi Ray,
Here's my implementation of SetCharset().
SV *
PerlClientApi::SetCharset( const char *c )
{
CharSetApi::CharSet cs = CharSetApi::Lookup( c );
if( cs == (CharSetApi::CharSet) -1 )
{
warn( "Unknown charset ignored. Check your code or P4CHARSET." );
return &PL_sv_undef;
}
client->SetTrans( cs, cs, cs, cs );
client->SetCharset( c );
return &PL_sv_yes;
}
So you can see I call _both_ ClientApi::SetCharset() and ClientApi::SetTrans()
to cover all the bases - and yes, it definitely works.
For what it's worth ClientApi::SetCharset() is very limited and SetTrans() is
the one that does the real work. SetCharset() is nice because it stores the
textual name of the charset which we can later retrieve with GetCharset().
Tony
> OK. Thanks. Did you verify that you can indeed connect to a
> Unicode-enabled Perforce server using only the SetCharset method? In my
> testing under Windows XP, I found that I could not get past the error
> "Unicode server permits only unicode enabled clients." until I invoked
> the SetTrans method:
>
> Changelist #45056 states:
>
> "The ClientApi::SetTrans method sets up client character set
> translations and must be called before connecting to a P4D operating in
> I18N mode. (i.e. call SetTrans before calling Init) See i18nnotes.txt
> for more information on I18N mode. "
>
> Thanks,
>
> Ray
>
> Tony Smith wrote:
> >Hi Ray,
> >
> >I've integrated your patch (with some modifications) into the main P4Perl
> >codeline. The main difference as far as you're concerned is that
> >P4::SetTrans() is not defined.
> >
> >Instead, I've chosen to expose only: P4::SetCharset() and P4::GetCharset()
> > and to implement the former in terms of ClientApi::SetCharset() and
> >ClientApi::SetTrans(). This keeps the interface simple at the Perl level
> >which is what I'm after.
> >
> >This does mean that you cannot use different translators for
> > filenames/file content/dialogs etc. as you can with a raw interface to
> > SetTrans(). I decided that's not something I want to support in P4Perl
> > since hardly anyone will either (a) need it or (b) understand it without
> > being able to read a lot more code than is in the public API.
> >
> >Thanks again for the change, and let me know if the above causes you any
> >problems.
> >
> >Regards,
> >
> >Tony
> >
> >On Thursday 02 December 2004 20:38, Raymond Danks wrote:
> >>Tony,
> >>
> >>I created a branch of the Perl Perforce API as of changelist 4608. I
> >>modified the API to support GetCharset, SetCharset, and SetTrans API
> >>calls. These are necessary for connecting to unicode enabled Perforce
> >>servers. I did what I needed to do to get it working functionally for
> >>my purposes. You may need to clean up the documentation some, but I
> >>think this will be useful to other users as well.
> >>
> >>//guest/raymond_danks/perforce/API/Perl/P4/...@4672
>
> !DSPAM:41b5db67120548441442119!