public class StringFunctions
extends java.lang.Object
Integer.MAX_VALUE
can be used instead -1 too.
Modifier and Type | Field and Description |
---|---|
static char |
cEndOfText
The char used to code end of text.
|
static char |
cNoCidentifier
The char used to coding any char which is not an identifier character
usual in programming languages like C, Java: A..Z a..z 0..9 _.
|
static char |
cStartOfText
The char used to code start of text.
|
(package private) static java.lang.String |
indentString |
static java.lang.String |
version
Version, history and license.
|
Constructor and Description |
---|
StringFunctions() |
Modifier and Type | Method and Description |
---|---|
static short |
byte2UTF8(byte[] src,
int[] ixSrc)
Converts the current bytes in a byte[] from UTF-8 in a UTF16-character.
|
static int |
compare(java.lang.CharSequence s1,
java.lang.CharSequence s2)
Compares two Strings or StringBuilder-content or any other CharSequence.
|
static int |
compare(java.lang.CharSequence s1,
int from1,
java.lang.CharSequence s2,
int from2,
int nrofChars)
Compares two CharSequence (Strings, StringBuilder-content etc.
|
static int |
compareChars(java.lang.CharSequence s1,
int from,
int to,
java.lang.CharSequence s2)
Compare two character Strings.
|
static int |
comparePos(java.lang.CharSequence s1,
java.lang.CharSequence s2)
Compares two CharSequence (Strings, StringBuilder-content etc.
|
static int |
comparePos(java.lang.CharSequence s1,
int from1,
java.lang.CharSequence s2,
int from2,
int nrofChars)
Compares two CharSequence (Strings, StringBuilder-content etc.)
|
static int |
compareWhSpacePos(java.lang.CharSequence s1,
int from1,
int to1,
java.lang.CharSequence s2,
int from2,
int to2,
int[] p2Out)
Compare two Strings whereby white spaces are ignored.
|
static boolean |
contains(java.lang.CharSequence s1,
java.lang.CharSequence s2)
Returns true if s2 is contained in s1.
|
static java.lang.CharSequence |
convertTransliteration(java.lang.CharSequence src,
char transcriptChar)
Resolves the given String containing some transcription chars (usual backslash)
to a string with the appropriate character codes.
|
static int |
copyToBuffer(java.lang.String src,
byte[] buffer,
java.nio.charset.Charset encoding)
Copies the content of a String in the given byte buffer with the requested encoding.
|
static int |
copyToBuffer(java.lang.String src,
char[] buffer)
Copies the content of a String in the given char buffer.
|
static boolean |
endsWith(java.lang.CharSequence sq,
java.lang.CharSequence end)
Checks whether the given CharSequence ends with a CharSequence.
|
static boolean |
equals(java.lang.CharSequence s1,
java.lang.CharSequence s2)
Compares two Strings or StringBuilder-content or any other CharSequence.
|
static boolean |
equals(java.lang.CharSequence s1,
int from,
int to,
java.lang.CharSequence s2)
Compares two charsequences.
|
static java.lang.String |
indent2(int indent)
Returns a String with 2*indent spaces for indentation.
|
static int |
indexAfterAnyChar(java.lang.CharSequence sq,
int begin,
int endMax,
java.lang.CharSequence sChars)
Searches the first character which is not contains in any given characters.
|
static int |
indexAfterIdentifier(java.lang.CharSequence src,
int start,
int endMax,
java.lang.String additionalChars)
Returns the position after the end of an identifier.
|
static int |
indexAfterIdentifierOld(java.lang.CharSequence src,
int start,
int endMax,
java.lang.String additionalChars)
Deprecated.
|
static int |
indexIdentifier(java.lang.CharSequence src,
int start,
int endMax,
java.lang.String additionalStartChars)
Searches the position of the first identifier character starting from the given position.
|
static int |
indexNoWhitespace(java.lang.CharSequence src,
int start,
int endMax)
Searches the first non-whitespace in src from start till at maximal endMax.
|
static int |
indexOf(java.lang.CharSequence sq,
char ch)
Searches the first occurrence of the given Character in a CharSequence.
|
static int |
indexOf(java.lang.CharSequence sq,
char ch,
int fromIndex)
Searches the first occurrence of the given Character in a CharSequence.
|
static int |
indexOf(java.lang.CharSequence sq,
java.lang.CharSequence str)
Searches the first occurrence of the given CharSequence in a CharSequence.
|
static int |
indexOf(java.lang.CharSequence sq,
java.lang.CharSequence str,
int fromIndex)
Searches the first occurrence of the given CharSequence in a CharSequence.
|
static int |
indexOf(java.lang.CharSequence sq,
int fromIndex,
int to,
char ch)
Searches the first occurrence of the given character in a CharSequence.
|
static int |
indexOf(java.lang.CharSequence sq,
int fromIndex,
int to,
java.lang.CharSequence str)
Checks whether the given CharSequence contains the other given CharSequence.
|
static int |
indexOf(java.lang.CharSequence sq,
int fromIndex,
int to,
java.lang.String str)
Checks whether the given CharSequence contains the other given CharSequence.
|
static int |
indexOfAnyChar(java.lang.CharSequence sq,
int begin,
int endMax,
java.lang.CharSequence sChars)
Searches any char inside sChars in the given Charsequence
|
static int |
indexOfAnyChar(java.lang.CharSequence sq,
int begin,
int endMax,
java.lang.CharSequence sChars,
int[] nr)
Searches any char inside sChars in the given CharSequence.
|
static int |
indexOfAnyCharOutsideQuotation(java.lang.CharSequence sq,
int begin,
int endMax,
java.lang.CharSequence sChars,
java.lang.CharSequence sQuotChars,
java.lang.CharSequence sQuotEndChars,
char transcriptChar,
int[] nr)
Searches the first occurrence of some given characters in a CharSequence
whereby characters in quotation are not checked.
|
static int |
indexOfAnyString(java.lang.CharSequence sq,
int from,
int to,
java.lang.CharSequence[] listStrings,
int[] nrofFoundString,
java.lang.String[] foundString)
Returns the position of one of the strings in listStrings within the given sq, maybe started inside the sq with from,
returns -1 if the char is not found in the part started from 'fromIndex'.
|
static int |
indexOutsideQuotation(java.lang.CharSequence sq,
int begin,
int endMax,
char csearch,
java.lang.CharSequence sQuotChars,
java.lang.CharSequence sQuotEndChars,
char transcriptChar)
Searches the first occurrence of the given character in a CharSequence
whereby characters in quotation are not checked.
|
static int |
indexWhitespace(java.lang.CharSequence src,
int start,
int endMax)
Searches the first whitespace in src from start till at maximal endMax.
|
static boolean |
isEmptyOrOnlyWhitespaces(java.lang.CharSequence text)
Returns false if at least one char was found in text which is not a whitespace.
|
static int |
lastIndexOf(java.lang.CharSequence sq,
char ch)
Searches the last occurrence of the given char in a CharSequence.
|
static int |
lastIndexOf(java.lang.CharSequence sq,
int from,
int end,
char ch)
Searches the last occurrence of the given char in a CharSequence.
|
static int |
lastIndexOf(java.lang.CharSequence sq,
int fromIndex,
int to,
java.lang.CharSequence str)
Checks whether the given CharSequence contains the other given CharSequence.
|
static int |
lastIndexOf(java.lang.CharSequence sq,
int fromIndex,
int to,
java.lang.String str)
Checks whether the given CharSequence contains the given String.
|
static int |
lastIndexOfAnyChar(java.lang.CharSequence sq,
int from,
int to,
java.lang.CharSequence chars)
Searches the last occurrence of one of the given chars in a CharSequence.
|
static int |
lastIndexOfNoChar(java.lang.CharSequence sq,
int from,
int to,
java.lang.CharSequence chars)
Searches the last occurrence in a CharSequence of any char which is not given in chars.
|
static java.lang.String |
nl_indent2(int indent)
Returns a String with a newline \n character and 2*indent spaces for indentation.
|
static int |
nrofBytesUTF8(byte b)
Returns the number of bytes to the UTF start byte.
|
static int |
posAfterIdentifier(java.lang.CharSequence src,
int start,
int endMax)
Deprecated.
|
static int |
posAfterIdentifier(java.lang.CharSequence src,
int start,
int endMax,
java.lang.String additionalStartChars,
java.lang.String additionalChars)
Deprecated.
|
private static int |
skipOverQuotation(java.lang.CharSequence sq,
int pos,
int endMax,
char cc,
java.lang.CharSequence sQuotChars,
java.lang.CharSequence sQuotEndChars,
int zQu,
char transcriptChar)
Only internal used.
|
static boolean |
startsWith(java.lang.CharSequence sq,
java.lang.CharSequence start)
Checks whether the given CharSequence starts with a defined CharSequence.
|
static boolean |
startsWith(java.lang.CharSequence sq,
int from,
int endMax,
java.lang.CharSequence start)
Checks whether the given CharSequence starts with a CharSequence.
|
static int |
startsWithAfterAnyChar(java.lang.CharSequence sq,
java.lang.CharSequence start,
java.lang.String anyCharBeforeStart)
Checks whether a given sq starts with the compare sequence start,
but after some admissible characters.
|
(package private) boolean |
test(java.lang.String s) |
(package private) int |
utf16toUTF8bytes(char cc,
byte[] buffer,
int posBuffer)
Converts a UTF16 character to 1..3 bytes UTF8
|
static short |
utf8to16(byte[] src,
int[] ixSrc)
Converts the current bytes in a byte[] from UTF-8 in a UTF16-character.
|
static java.lang.String |
z_StringJc(char[] buffer)
Converts a String in a buffer in a java.lang.String.
|
public static final java.lang.String version
indexAfterIdentifier(CharSequence, int, int, String)
returns 0 if the position starts with a number.
That is proper also for test whether currently it is an identifier and it is consequent.
The old behavior of this operation is now available in indexAfterIdentifierOld(CharSequence, int, int, String)
.
startsWith(CharSequence, CharSequence)
: was faulty if number of chars to compare is equal the length.
comparePos(CharSequence, int, CharSequence, int, int)
:
If any String is longer than nrofChars but the rest is equal, now returns 0. (Before, returns a value > nrofChars).
startsWithAfterAnyChar(CharSequence, CharSequence, String)
, new indexAfterAnyChar(CharSequence, int, int, CharSequence)
compareWhSpacePos(CharSequence, int, int, CharSequence, int, int, int[])
indexOfAnyCharOutsideQuotation(CharSequence, int, int, CharSequence, CharSequence, CharSequence, char, int[])
etc, handling quotations, here also (not only in StringPart
, used for CmdExecuter.splitArgs(String, int, int)
comparePos(CharSequence, int, CharSequence, int, int)
: change on 2021-20-04 was wrong!
The problem is, if the first char is different, it should not return 0, because that means equal. It should retunr 1 or -1
Because of that sometimes a bad directory was selected in Fcmd (a non exist new directory was detected as the last used).
utf16toUTF8bytes(char, byte[], int)
but also not tested and not used but may be correct.
utf8to16(byte[], int[])
instead link #byte2UTF8(byte[], int[])} but: this function is not tested
and may be not used yet, may be not correct.
comparePos(CharSequence, int, CharSequence, int, int)
: return was one time to high.
comparePos(CharSequence, int, CharSequence, int, int)
for comparing empty strings
indexOfAnyChar(CharSequence, int, int, CharSequence, int[])
returns the number of the found character too
equals(CharSequence, int, int, CharSequence)
nrofBytesUTF8(byte)
used in StringPartFromFileLines
indexOfAnyString(CharSequence, int, int, CharSequence[], int[], String[])
: Algorithm from StringPart
copied to here. It is common. temporary instance in StrinPart prevented.
StringFunctions_C
.
Reason: Dissipate the content because for some embedded applications a fine tuning of used sources is necessary.
indexWhitespace(CharSequence, int, int)
, indexNoWhitespace(CharSequence, int, int)
.
indexAfterIdentifier(CharSequence, int, int, String)
equals(CharSequence, int, int, CharSequence)
regards null-pointer too.
indexOf(CharSequence, int, int, String)
and indexOf(CharSequence, int, int, CharSequence)
.
Twice methods lastIndexOf(CharSequence, int, int, String)
and lastIndexOf(CharSequence, int, int, CharSequence)
.
The methods are the same in Java. But in C the handling of reference is different. In Java2C translation a StringJc does not base on CharSequence
because it is a simple reference to char[] and a length only. CharSequence needs ObjectJc and virtual methods.
#indexOfAnyChar(CharSequence, int, int, String)
: Algorithm transfered from
StringPart#indexOfAnyChar(String, int, int, char, char, char)
to this class for common usage,
called in StringPart. TODO do it with all that algoritm.
cEndOfText
now defined here, parallel to StringPart#cEndOfText
.
Note: that char is ASCII but not UTF.
indent2(int)
#parseFloat(String, int, int, char, int[])
with choiceable separator (123,45, german decimal point)
#convertTranscription(CharSequence, char)
used form SpecialCharStrings#resolveCircumScription(String)
compare(CharSequence, int, CharSequence, int, int)
, indexOf(CharSequence, CharSequence, int)
#parseIntRadix(String, int, int, int, int[], String)
now can skip
over some characters. In this kind a number like 2"123'456.1 is able to read.
#parseLong(String, int, int, int, int[], String)
as counterpart to parseInt
isEmptyOrOnlyWhitespaces(CharSequence)
compare(CharSequence, int, CharSequence, int, int)
,
startsWith(CharSequence, CharSequence)
, endsWith(CharSequence, CharSequence)
,
indexOf(CharSequence, char, int)
, indexOf(CharSequence, CharSequence, int)
Generally usage of CharSequence as StringBuilder instance saves calculation time in comparison with usage String,
because a new allocation is saved. This saving can be done any time if the StringBuilder is non thread-shared
and its reference is not stored permanently but only used immediately in the thread.
compare(CharSequence, CharSequence)
and Object.equals(Object)
.
copyToBuffer(String, char[])
and copyToBuffer(String, byte[], Charset)
:
This methods are existent at the C-level. They are usefully if dynamic memory usage should be prevented.
They are need for Java-usage with static data too.
#parseIntRadix(String, int, int, int, int[])
etc.
taken from C-Sources CRunntimeJavalike/source/Fwc/fw_Simple.c
public static final char cEndOfText
public static final char cStartOfText
public static final char cNoCidentifier
static java.lang.String indentString
public static int indexWhitespace(java.lang.CharSequence src, int start, int endMax)
src
- start
- endMax
- >=0: absolute exclusive end position for search, <0: end position relative to end, -1 is the end of srcpublic static int indexNoWhitespace(java.lang.CharSequence src, int start, int endMax)
src
- start
- endMax
- >=0: absolute exclusive end position for search, <0: end position relative to end, -1 is the end of srcpublic static int indexIdentifier(java.lang.CharSequence src, int start, int endMax, java.lang.String additionalStartChars)
src
- start
- endMax
- >=0: absolute exclusive end position for search, <0: end position relative to end, -1 is the end of srcadditionalStartChars
- null: do not use,@Deprecated public static int indexAfterIdentifierOld(java.lang.CharSequence src, int start, int endMax, java.lang.String additionalChars)
src
- The input stringstart
- at this position the identifier starts.endMax
- >=0: absolute exclusive end position for search, <0: end position relative to end, -1 is the end of srcadditionalChars
- maybe null, some chars as additional chars of an identifier, inside and as start.public static int indexAfterIdentifier(java.lang.CharSequence src, int start, int endMax, java.lang.String additionalChars)
src
- If the first char on [start] is 0..9 it returns 0, it is not an identifier.start
- from this positionendMax
- >=0: absolute exclusive end position for search, <0: end position relative to end, -1 is the end of srcadditionalChars
- maybe null, some chars as additional chars of an identifier, inside and as start.@Deprecated public static int posAfterIdentifier(java.lang.CharSequence src, int start, int endMax, java.lang.String additionalStartChars, java.lang.String additionalChars)
indexAfterIdentifier(CharSequence, int, int, String)
src
- The input stringstart
- at this position the identifier starts.endq
- max number of chars to checkadditionalStartChars
- maybe null, some chars as additional start chars of an identifier.additionalChars
- maybe null, some chars as additional chars of an identifier.@Deprecated public static int posAfterIdentifier(java.lang.CharSequence src, int start, int endMax)
indexAfterIdentifier(CharSequence, int, int, String)
src
- The input stringstart
- at this position the indentier starts.endq
- max number of chars to checkpublic static int copyToBuffer(java.lang.String src, byte[] buffer, java.nio.charset.Charset encoding)
src
- The src Stringbuffer
- The desination buffer with given length. The last byte will be set to 0.encoding
- The encoding. If null, then use the UTF8-encoding.public static int copyToBuffer(java.lang.String src, char[] buffer)
src
- The src Stringbuffer
- The desination buffer with given length. The last byte will be set to 0.public static java.lang.String z_StringJc(char[] buffer)
buffer
- It is zero-terminated.public static int comparePos(java.lang.CharSequence s1, java.lang.CharSequence s2)
String.compareTo(String)
.
but it works proper with CharSequence
. See example on Object.equals(Object)
.s1
- left char sequences2
- right char sequencepublic static int comparePos(java.lang.CharSequence s1, int from1, java.lang.CharSequence s2, int from2, int nrofChars)
String.compareTo(String)
or compare(CharSequence, int, CharSequence, int, int)
s1
- left char sequencefrom1
- start positions2
- right char sequencefrom2
- start positionnrofChars
- maximal number of chars to compare. It can be negative or Integer.MAX_VALUE
to compare all characters to the end. Use -1 to compare all characters is recommended.
Note: if 0, the return value of this method is 0 because all (=0) characters are equal. This may be important for some extrem situations.public static int compareWhSpacePos(java.lang.CharSequence s1, int from1, int to1, java.lang.CharSequence s2, int from2, int to2, int[] p2Out)
s1
- Any string, can be nullfrom1
- start positionto1
- -1 then till end, -2... before end, positive: number of charss2
- Second Stringfrom2
- to2
- p2Out
- null or an int[1] variable for the error position in s2boolean test(java.lang.String s)
public static int compare(java.lang.CharSequence s1, int from1, java.lang.CharSequence s2, int from2, int nrofChars)
String.compareTo(String)
.
but it works proper with CharSequence
. See example on Object.equals(Object)
.s1
- left char sequence, maybe null, then return -1 or 0 (both null)from1
- start positions2
- right char sequence, maybe null, then return 0 (both null) or 1.from2
- start positionnrofChars
- maximal number of chars to compare. It can be Integer.MAX_VALUE
to compare all characters to the end.public static int compare(java.lang.CharSequence s1, java.lang.CharSequence s2)
String.compareTo(String)
.s1
- s2
- public static boolean equals(java.lang.CharSequence s1, int from, int to, java.lang.CharSequence s2)
s1
- first, if null then returns true if s2== null. Equals is both null too.from
- start position in s1to
- exclusive end position in s1, if <0, especially -1 or > s1.length, then till length of s1. That is 'endsWith'.s2
- to compare withpublic static int compareChars(java.lang.CharSequence s1, int from, int to, java.lang.CharSequence s2)
public static boolean equals(java.lang.CharSequence s1, java.lang.CharSequence s2)
String.equals(Object)
.
But the String.equals(Object)
does only compare instances of Strings,
it does not compare a String with any other CharSequence
whether there are equal.
Not that: String str = "abc"; String str2 = "abc"; StringBuilder sb = new StringBuilder(str); assert(str.equals(str2)); assert(str.contentEquals(sb)); //special String comparator assert( ! str.equals(sb)); //it is not equals, sb is not a String. assert(StringFunctions.equals(str, sb)); assert(StringFunctions.equals(sb, str)); //compares any CharSequences
s1
- s2
- public static boolean contains(java.lang.CharSequence s1, java.lang.CharSequence s2)
indexOf(CharSequence, int, int, CharSequence)
.public static boolean startsWith(java.lang.CharSequence sq, java.lang.CharSequence start)
String.startsWith(String)
but it works proper with CharSequence
. See example on Object.equals(Object)
.public static int startsWithAfterAnyChar(java.lang.CharSequence sq, java.lang.CharSequence start, java.lang.String anyCharBeforeStart)
sq
- The string to checkstart
- start characters to checkanyCharBeforeStart
- often only one space, or specific indent character.public static boolean startsWith(java.lang.CharSequence sq, int from, int endMax, java.lang.CharSequence start)
String.startsWith(String)
but it works proper with CharSequence
. See example on Object.equals(Object)
.endMax
- >=0: absolute exclusive end position for search, <0: end position relative to end, -1 is the end of srcpublic static boolean endsWith(java.lang.CharSequence sq, java.lang.CharSequence end)
String.startsWith(String)
but it works proper with CharSequence
. See example on Object.equals(Object)
.public static boolean isEmptyOrOnlyWhitespaces(java.lang.CharSequence text)
text
- to checkpublic static int indexOf(java.lang.CharSequence sq, int fromIndex, int to, char ch)
java.lang.String#indexOf(char, int)
.sq
- search intofromIndex
- start searchto
- >=0: absolute exclusive end position for search, <0: end position relative to end, -1 is the end of srcch
- The character which is searched.public static int indexOf(java.lang.CharSequence sq, char ch, int fromIndex)
String.indexOf(String, int)
.sq
- A CharSequencestr
- CharSequence which is searched.fromIndex
- first checked position in sqpublic static int indexOf(java.lang.CharSequence sq, char ch)
String.indexOf(String)
.sq
- A CharSequencestr
- CharSequence which is searched.public static int indexOfAnyChar(java.lang.CharSequence sq, int begin, int endMax, java.lang.CharSequence sChars, int[] nr)
sq
- The String to search inbegin
- start position to search in sqendMax
- >=0: absolute exclusive end position for search, <0: end position relative to end, -1 is the end of srcsChars
- Some chars to search in sq
If sChars contains a EOT character (code 03, cEndOfText
) then the search stops at this character
or it is continued to the end of the range in sq. Then the length of the text range is returned
if another character in sChars is not found.
It means: The end of the text range is adequate to an EOT-character. Note that EOT is not unicode,
but it is an ASCII control character.nr
- null or initialized with new int[1], then returns the number of the found character in sChars from 0public static int indexAfterAnyChar(java.lang.CharSequence sq, int begin, int endMax, java.lang.CharSequence sChars)
sq
- search this stringbegin
- >=0 for startendMax
- >=0: absolute exclusive end position for search, <0: end position relative to end, -1 is the end of srcsChars
- This characters are skippedprivate static int skipOverQuotation(java.lang.CharSequence sq, int pos, int endMax, char cc, java.lang.CharSequence sQuotChars, java.lang.CharSequence sQuotEndChars, int zQu, char transcriptChar)
sq
- pos
- current, maybe a quotation or not, this operation tests it.endMax
- cc
- character on sq[pos]sQuotChars
- maybe nullsQuotEndChars
- maybe nullzQu
- transcriptChar
- public static int indexOutsideQuotation(java.lang.CharSequence sq, int begin, int endMax, char csearch, java.lang.CharSequence sQuotChars, java.lang.CharSequence sQuotEndChars, char transcriptChar)
indexOf(CharSequence, char)
or adequate java.lang.String#indexOf(char, int)
but regarding quotation.sq
- search intobegin
- start searchendMax
- >=0: absolute exclusive end position for search, <0: end position relative to end, -1 is the end of srccsearch
- The character which is searched.sQuotChars
- null or List of possible start quotation character, for example "\"'"sQuotEndChars
- null or List of associated end quotation character. If null then the same as start character are used (familiar for "")transcriptChar
- Character after this char is not checked, usual \ for transcription of \", \n etc.public static int indexOfAnyCharOutsideQuotation(java.lang.CharSequence sq, int begin, int endMax, java.lang.CharSequence sChars, java.lang.CharSequence sQuotChars, java.lang.CharSequence sQuotEndChars, char transcriptChar, int[] nr)
indexOf(CharSequence, char)
or adequate java.lang.String#indexOf(char, int)
but regarding quotation.sq
- search intobegin
- start searchendMax
- >=0: absolute exclusive end position for search, <0: end position relative to end, -1 is the end of srcsChars
- Some characters which are searched.sQuotChars
- null or List of possible start quotation character, for example "\"'"sQuotEndChars
- null or List of associated end quotation character. If null then the same as start character are used (familiar for "")transcriptChar
- Character after this char is not checked, usual \ for transcription of \", \n etc.public static int indexOfAnyChar(java.lang.CharSequence sq, int begin, int endMax, java.lang.CharSequence sChars)
begin
- start position to search in sqendMax
- >=0: absolute exclusive end position for search, <0: end position relative to end, -1 is the end of srcsChars
- Some chars to search in sq
If sChars contains a EOT character (code 03, cEndOfText
) then the search stops at this character
or it is continued to the end of the range in sq. Then the length of the text range is returned
if another character in sChars is not found.
It means: The end of the text range is adequate to an EOT-character. Note that EOT is not unicode,
but it is an ASCII control character.public static int lastIndexOf(java.lang.CharSequence sq, int from, int end, char ch)
java.lang.String#lastIndexOf(char, fromEnd)
.sq
- Any sequencefrom
- range, it ends searching on fromend
- >=0: absolute exclusive end position for search, <0: end position relative to end, -1 is the end of srcch
- to searchpublic static int lastIndexOf(java.lang.CharSequence sq, char ch)
java.lang.String#lastIndexOf(char)
.sq
- A CharSequencestr
- CharSequence which is searched.public static int lastIndexOfAnyChar(java.lang.CharSequence sq, int from, int to, java.lang.CharSequence chars)
sq
- Any sequencefrom
- range, it ends searching on from
if from < 0 it throws IndexOutOfBoundsExceptionto
- start backward from here
if > sq.length() starts from end as well as to = -1
if to < from then returns -1 always.
if to < 0 then starts from end - to, use to = -1 to start from end to = -2 to start one for endchars
- to search forjava.lang.IndexOutOfBoundsException
- if from < 0 or to < 0public static int lastIndexOfNoChar(java.lang.CharSequence sq, int from, int to, java.lang.CharSequence chars)
sq
- Any sequencefrom
- range, it ends searching on from
if from < 0 it throws IndexOutOfBoundsExceptionto
- start backward from here
if > sq.length() starts from end as well as to = -1
if to < from then returns -1 always.
if to < 0 then starts from end - to, use to = -1 to start from end to = -2 to start one for endchars
- to search for, for example " \t\n\r" to search the last non-whitespace chararcterjava.lang.IndexOutOfBoundsException
- if from < 0 or to < 0public static int indexOf(java.lang.CharSequence sq, int fromIndex, int to, java.lang.String str)
String.indexOf(String, int)
.sq
- A CharSequencefromIndex
- first checked position in sqto
- >=0 then end position of checked range inclusive str
to <0 then relative position from end. to = -1 exact till endstr
- which is searched.public static int indexOf(java.lang.CharSequence sq, int fromIndex, int to, java.lang.CharSequence str)
String.indexOf(String, int)
.sq
- A CharSequencestr
- CharSequence which is searched.fromIndex
- first checked position in sqto
- >=0: absolute exclusive end position for search, <0: end position relative to end, -1 is the end of srcpublic static int indexOf(java.lang.CharSequence sq, java.lang.CharSequence str, int fromIndex)
String.indexOf(String, int)
.sq
- A CharSequencestr
- CharSequence which is searched.fromIndex
- first checked position in sqequals(CharSequence sq, int return , int MAX_VALUE, CharSequence str)
==0.public static int indexOf(java.lang.CharSequence sq, java.lang.CharSequence str)
String.indexOf(String)
.sq
- A CharSequencestr
- CharSequence which is searched.equals(CharSequence sq, int return , int MAX_VALUE, CharSequence str)
==0.public static int lastIndexOf(java.lang.CharSequence sq, int fromIndex, int to, java.lang.String str)
String.lastIndexOf(String, int)
.sq
- Any sequence where to search infrom
- range, it ends searching on fromto
- >=0: absolute exclusive end position for search, <0: end position relative to end, -1 is the end of srcstr
- comparison String, check whether contained fully.public static int lastIndexOf(java.lang.CharSequence sq, int fromIndex, int to, java.lang.CharSequence str)
#lastIndexOfAnyChar(CharSequence, int, int, String)
.
The difference is by translating to C source.sq
- Any sequence where to search infrom
- range, it ends searching on fromto
- >=0: absolute exclusive end position for search, <0: end position relative to end, -1 is the end of srcstr
- comparison sequence, check whether contained fully.public static int indexOfAnyString(java.lang.CharSequence sq, int from, int to, java.lang.CharSequence[] listStrings, int[] nrofFoundString, java.lang.String[] foundString)
from
- begin of search within the part.to
- >=0: absolute exclusive end position for search, <0: end position relative to end, -1 is the end of srclistStrings
- contains some Strings to find.nrofFoundString
- If given, [0] is set with the number of the found String in listStrings,
count from 0. This array reference may be null, then unused.foundString
- If given, [0] is set with the found String. This array reference may be null.public static java.lang.CharSequence convertTransliteration(java.lang.CharSequence src, char transcriptChar)
cStartOfText
.
It is useful wether a String may be contain a code for start of text.
cEndOfText
.
src
- The input stringtranscriptChar
- the transcript character, usual a '\\'public static java.lang.String indent2(int indent)
indent
- indentationpublic static java.lang.String nl_indent2(int indent)
indent
- indentationpublic static int nrofBytesUTF8(byte b)
b
- any byte of a UTF8 stream.public static short byte2UTF8(byte[] src, int[] ixSrc)
src
- ixSrc
- public static short utf8to16(byte[] src, int[] ixSrc)
src
- any byte arrayixSrc
- [0] The current position in this byte array. It should refer the first byte of a UTF-8-coded character.
The ixSrc[0] will be incremented by the processed bytes for this one character. If the routine does not return 0,
than the ixSrc[0] refers the first byte of the next UTF8 character, or the end of the array.int utf16toUTF8bytes(char cc, byte[] buffer, int posBuffer)
cc
- The characterbuffer
- for bytesposBuffer
- first write position in buffer. The buffer size should be at least posBuffer +3https://en.wikipedia.org/wiki/UTF-8
, https://de.wikipedia.org/wiki/UTF-8