Package com.perforce.p4java.server
Class PerforceCharsets
java.lang.Object
com.perforce.p4java.server.PerforceCharsets
Encapsulates Perforce-wide charset information for servers.
Unfortunately, support for Unicode and associated charsets is somewhat server- and installation-dependent, and not easy to divine unless you're already talking to a Perforce server -- by which time it's too late. This class is an attempt to make it easier to cut that Gordian knot...
Note that the names below are not actually the standard name for the charset in some cases: e.g. UTF-8 should be "utf-8" not "utf8", but we follow the Perforce server's rules here.
The following are special cases.
"auto" (Guess a P4CHARSET based on client OS params) "none" (same as unsetting P4CHARSET)
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringgetJavaCharsetName(String p4CharsetName) Get Java equivalent charset name for a p4 charset namestatic String[]Get known P4 charsetsstatic CharsetgetP4Charset(String p4CharsetName) Get the matching Java charset for a given P4 charset name.static StringgetP4CharsetName(String javaCharsetName) Get the first matching Perforce equivalent charset name for a given Java charset name.static booleanhasClientBOM(String p4CharsetName) static booleanisSupported(String p4CharsetName) Is the P4 charset name specified supported?
-
Constructor Details
-
PerforceCharsets
public PerforceCharsets()
-
-
Method Details
-
getKnownCharsets
Get known P4 charsets- Returns:
- - array of p4 charset names
-
getP4CharsetName
Get the first matching Perforce equivalent charset name for a given Java charset name. Multiple Perforce charsets can be mapped to a Java charset (i.e. Perforce "utf8-bom" and "utf8unchecked" are mapped to Java "UTF-8")- Parameters:
javaCharsetName- charset- Returns:
- - Perforce charset name
-
getP4Charset
Get the matching Java charset for a given P4 charset name.- Parameters:
p4CharsetName- charset- Returns:
- - Java charset
-
getJavaCharsetName
Get Java equivalent charset name for a p4 charset name- Parameters:
p4CharsetName- charset- Returns:
- - Java charset name
-
hasClientBOM
- Parameters:
p4CharsetName- charset- Returns:
- true, if client charset has BOM
-
isSupported
Is the P4 charset name specified supported?- Parameters:
p4CharsetName- charset- Returns:
- - true if supported, false otherwise
-