C# Class SIL.CoreImpl.TsStringUtils

TsStringUtils is a collection of static methods for working with TS strings.
Exibir arquivo Open project: sillsdev/FieldWorks

Public Properties

Property Type Description
kRegexUrl System.Text.RegularExpressions.Regex

Public Methods

Method Description
Compose ( string source ) : string

Returns a string an NFC (normalized form, composed) form of a Unicode string.

CreateOrcFromGuid ( System.Guid guid, FwObjDataTypes type, int ws ) : ITsString

Creates an object replacement character from a Guid

DeleteOrcFromBuilder ( ITsStrBldr tssBldr, System.Guid guidToRemove ) : int

Remove all reference ORCs for the specified builder

FindTextInString ( ITsString wordFormTss, ITsString sourceTss, ILgWritingSystemFactory wsf, bool fMatchWholeWord, int &ichMin, int &ichLim ) : bool

Determine if the specified text exists in the string

TODO: Add a parameter to make it possible to do a case-insensitive match?

FindWordFormInString ( ITsString wordFormTss, ITsString sourceTss, ILgWritingSystemFactory wsf, int &ichMin, int &ichLim ) : bool

Determine if the word form exists in the string, matching the whole word or sequence of words.

TODO: Add a parameter to make it possible to do a case-insensitive match?

GetCharPropEngineAtOffset ( ITsString tss, ILgWritingSystemFactory wsf, int ich ) : ILgCharacterPropertyEngine

Get the character property engine that should be used for interpreting the character at ich.

GetCleanSingleRunTsString ( ITsString tss ) : ITsString

Gets a TsString made from the ashes of the input parameter which has: 1) only one run 2) uses the ws of the 1st run of the input TsString.

GetCleanTextFromTsString ( ITsString tss, IEnumerable stylesToRemove, bool fStopOnRemovedStyle, ILgWritingSystemFactory writingSystemFactory ) : string

Get the text from a ITsString, removing ORCs and any text in the specified character styles. Also trims any non-wordforming characters from the beginning and the end of the text.

GetCleanTsString ( ITsString tss ) : ITsString

Gets a TsString with no: 1) ORCs corresponding to special runs, or 2) clipboard- style footnote or picture runs.

GetCleanTsString ( ITsString tss, IEnumerable stylesToRemove ) : ITsString

Gets a TsString with no: 1) leading and trailing spaces, 2) ORCs, 3) clipboard-style footnote runs, or 4) runs having the specified character styles.

GetCleanTsString ( ITsString tss, IEnumerable stylesToRemove, bool fStopOnRemovedStyle, bool fPreserveUnknownOrcs, bool fTrimSpaces ) : ITsString

Gets a TsString with no: 1) ORCs (except maybe unknown ones, if so requested), 3) clipboard-style footnote runs, or 4) runs having the specified character styles. Also, leading and trailing spaces are removed if requested.

GetDiffsInTsStrings ( ITsString tssOld, ITsString tssNew ) : TsStringDiffInfo

Get an indication of the range of characters that differ between two TsStrings. Return null if they are equal If they are not, ichMin indicates the first different character (or the length of the shorter string). cvIns indicates how many characters must be inserted at ichMin, after deleting cvDel, to get tssNew. Character properties as well as values are considered. If it is ambiguous where the difference occurs, we first try to interpret the difference in a way that equates to inserting or deleting a complete word, otherwise, prefer to find the longest common string at the start.

GetFirstVernacularWs ( string vernWsVecImage, ILgWritingSystemFactory wsf, ITsString text ) : int

Gets the first vernacular ws.

GetGuidFromProps ( ITsTextProps ttp, FwObjDataTypes desiredOrcTypes, FwObjDataTypes &odt ) : System.Guid

Get a Guid from the given text props.

GetGuidFromRun ( ITsString tss, int iRun ) : System.Guid

Get a Guid from the given run in a structured text string.

GetGuidFromRun ( ITsString tss, int iRun, FwObjDataTypes desiredOrcType ) : System.Guid

Get a Guid from the given run in a structured text string.

GetGuidFromRun ( ITsString tss, int iRun, FwObjDataTypes &odt, TsRunInfo &tri, ITsTextProps &ttp, FwObjDataTypes desiredOrcTypes ) : System.Guid

Get a Guid from the given run in a structured text string.

GetGuidFromRun ( ITsString tss, int iRun, ITsTextProps ttp ) : System.Guid

Get a Guid from the given run in a structured text string.

GetGuidFromRun ( ITsString tss, int iRun, TsRunInfo &tri, ITsTextProps &ttp ) : System.Guid

Get a Guid from the given run in a structured text string.

GetHotGuidFromObjData ( string sObjData ) : System.Guid

See if the string, typically obtained from a TsTextProps string property (int)FwTextPropType.ktptObjData, represents a hot link. If so, return the GUID of the object linked to. This overlaps some of the functionality of GetGuidFromProps and GetHotObjectGuidFromProps, for performance reasons.

GetHotObjectGuidFromProps ( ITsTextProps ttp ) : System.Guid

Get a "Hot" Guid from the given text props.

GetObjData ( System.Guid guid, byte objectDataType ) : byte[]

Get the string to pass as ObjData property

GetOwnedGuidFromRun ( ITsString tss, int iRun, FwObjDataTypes &odt ) : System.Guid

Get an owned Guid from the given run in a structured text string.

GetOwnedGuidFromRun ( ITsString tss, int iRun, FwObjDataTypes &odt, TsRunInfo &tri, ITsTextProps &ttp ) : System.Guid

Get an owned Guid from the given run in a structured text string.

GetOwnedORCs ( ITsString tss ) : ITsString

Gets the owned ORCs from the given ITsString.

GetTextProps ( System.Xml.Linq.XElement xml, ILgWritingSystemFactory wsf ) : ITsTextProps

Convert XML (produced by the above 'GetString' method) into an ITsTextProps.

GetURL ( string sProp ) : string

Gets the URL information in a form suitable for writing out in an .

GetUsefulGuidFromProps ( ITsTextProps ttp ) : System.Guid

Get a Guid from the given text props if the object type is a footnote or a picture.

GetWritingSystems ( ITsString tss ) : List

Return a list of the writing systems found in the string.

GetWsAtOffset ( ITsString tss, int ich ) : int

Get the ws at the given (ich) char offset in the tss.

GetWsOfRun ( ITsString tss, int irun ) : int

Get the writing system of the specified run of a TsString.

GetXmlRep ( ITsString tss, ILgWritingSystemFactory wsf, int ws ) : string

Get an XML representation of the given ITsString.

GetXmlRep ( ITsString tss, ILgWritingSystemFactory wsf, int ws, bool fWriteObjData ) : string

Get an XML representation of the given ITsString.

GetXmlRep ( ITsTextProps ttp, ILgWritingSystemFactory wsf ) : string

Get an XML representation of the given ITsTextProps.

InitIcuDataDir ( ) : void

Initialize the ICU Data directory based on the ICU data directory. It is safe to call this static method more than once, but necessary only to call it at least once.

InsertOrcIntoPara ( System.Guid guid, FwObjDataTypes objDataType, ITsStrBldr tsStrBldr, int ichMin, int ichLim, int ws ) : void

Insert (or replace) an ORC run in a string builder.

IsCharacterDefined ( string chr ) : bool

Determines whether or not the specified character is defined in ICU.

IsEndOfSentenceChar ( int ch, LgGeneralCharCategory cc ) : bool

Determines whether the given character is used to end a sentence.

IsHyperlink ( ITsTextProps ttp ) : bool

Checks to see if the text properties are for a hyperlink.

IsValidChar ( string chr, ILgCharacterPropertyEngine cpe ) : bool

Determines whether the specified string is a valid string consisting of exactly one initial base character followed by zero or more legally placed combining marks.

IsWhite ( ILgCharacterPropertyEngine cpe, string text, int ich ) : bool

Tells whether the full character (starting) at ich is a white-space character.

MakeTss ( ITsStrFactory tsf, int wsHvo, string text ) : ITsString

Create an ITsString in the given writing system.

MakeTss ( string src, int ws ) : ITsString

Create a new Tss based on the given string and ws.

MakeTss ( string text, int wsHvo, string styleName ) : ITsString

Create an ITsString in the given writing system and with the given style name.

MergeString ( ITsString source, ITsString dest ) : ITsString

Merges the string.

MergeString ( ITsString source, ITsString dest, bool fConcatenateIfBoth ) : ITsString

Merges the string.

NormalizeNfd ( ITsString source ) : ITsString

Normalizes the specified TsString in NFD form.

NormalizeNfd ( string source ) : string

Returns a string an NFD (normalized form, decomposed) form of a Unicode string. Enhance JohnT: This is not a very efficient implementation; we should be able to use some ICU method directly (as the ITsString implementation does). Fix if ever used for something high-performance!

NormalizeToNFC ( string s ) : string

Normalize the string for display. Uniscribe requires NFC. (See LT-4202 and LT-4203.)

ParseCharString ( string chars, string delimiter, ILgCharacterPropertyEngine cpe ) : List

Parses the specified string into a list of characters, ignoring any bogus characters (digraphs, undefined Unicode characters, lone diacritics, etc.). The unparsed list is a string of valid characters delimited with the specified delimiter.

ParseCharString ( string chars, string delimiter, ILgCharacterPropertyEngine cpe, List &invalidCharacters ) : List

Parses the specified string into a list of characters. The unparsed list is a string of valid characters delimited with the specified delimiter.

PropsForWs ( int ws ) : ITsTextProps

Answer a TsTextProps that specifies the given writing system (all other props have default values).

ReassignTss ( ITsString &tss, ITsString tssNewValue ) : void

Releases a tss string that was created with MakeString, before reassigning it. Especially useful in Dispose, since we check whether it is null before doing the release.

RemoveIllegalXmlChars ( ITsString input ) : ITsString

Remove characters that are illegal in XML files. Returns the input string if nothing is wrong with it.

RemoveIntProp ( ITsString tss, int intProp ) : ITsString

Removes the specified integer property from a Structured text string.

ReverseString ( string s ) : string

Reverse the order of characters within the string (make a mirror image of it). The tricky part, as always with UTF-16, is handling surrogate pairs correctly. TODO: Ideally this method should be in SilUtils.StringUtils. However, this method depends on the Surrogates class which is defined in BasicUtils which we didn't want to move just for this one method.

Split ( ITsString tss, string separator, StringSplitOptions opt ) : List

Split the ITsString into pieces separated by one of the strings in separator, and using the same options as String.Split().

TrimNonWordFormingChars ( ITsString untrimmedString, ILgWritingSystemFactory writingSystemFactory ) : ITsString

Trim the leading AND trailing non-word forming characters.

TrimNonWordFormingChars ( ITsString tssInput, ILgWritingSystemFactory writingSystemFactory, bool fTrimLeading, bool fTrimTrailing ) : ITsString

Trim the leading AND/OR trailing non-word forming characters.

TurnOwnedOrcIntoUnownedOrc ( ITsStrBldr bldr, int irun ) : void

Replaces the requested run of the given builder with an identical ORC but whose type is un-owned rather than owned. If the given run is not an ORC at all or is not owned, do nothing.

ValidateCharacterSequence ( string origChars, ILgCharacterPropertyEngine cpe ) : string

Finds the first base character/combining diacritic combination and removes any remaining characters.

WriteHref ( int tpt, string sProp, XmlWriter writer ) : bool

Writes an href element to the XML writer if the given string property is of the proper type.

Private Methods

Method Description
GetGuidFromRun ( ITsString tss, int iRun, FwObjDataTypes desiredOrcTypes, FwObjDataTypes &odt, TsRunInfo &tri, ITsTextProps &ttp ) : System.Guid

Get a Guid from the given run in a structured text string.

IsCodePointDefined ( int codepoint ) : bool

Determines whether or not the specified codepoint is defined in ICU. If it is and its a custom PUA character, then make sure the language definition's PUA character collection is updated. Return false if the codepoint is not defined in ICU.

IsIllegalXmlCharacter ( string text, int index ) : bool

See http://www.w3.org/TR/REC-xml/#charsets Also detects unmatched surrogates

IsMark ( char chr, ILgCharacterPropertyEngine cpe ) : bool

Determines whether the specified character is a mark (either as defined by the character property engine or as overridden by the language definition.

RemoveOneIllegalXmlCharacter ( ITsString input ) : ITsString

Remove one illegal character, if one is found; otherwise, return the original string.

Method Details

Compose() public static method

Returns a string an NFC (normalized form, composed) form of a Unicode string.
public static Compose ( string source ) : string
source string String to compose.
return string

CreateOrcFromGuid() public static method

Creates an object replacement character from a Guid
public static CreateOrcFromGuid ( System.Guid guid, FwObjDataTypes type, int ws ) : ITsString
guid System.Guid guid that maps to an ORC
type FwObjDataTypes type of ORC to return within the TsString
ws int The writing system.
return ITsString

DeleteOrcFromBuilder() public static method

Remove all reference ORCs for the specified builder
public static DeleteOrcFromBuilder ( ITsStrBldr tssBldr, System.Guid guidToRemove ) : int
tssBldr ITsStrBldr the builder
guidToRemove System.Guid guid of the ORC to remove
return int

FindTextInString() public static method

Determine if the specified text exists in the string
TODO: Add a parameter to make it possible to do a case-insensitive match?
public static FindTextInString ( ITsString wordFormTss, ITsString sourceTss, ILgWritingSystemFactory wsf, bool fMatchWholeWord, int &ichMin, int &ichLim ) : bool
wordFormTss ITsString text to look for
sourceTss ITsString text to search in
wsf ILgWritingSystemFactory source of char prop engines
fMatchWholeWord bool True to match a whole word, false otherwise
ichMin int The start of the string where the text was found (undefined if /// this method returns false)
ichLim int The limit (one character position past the end) of the string /// where the text was found (undefined if this method returns false)
return bool

FindWordFormInString() public static method

Determine if the word form exists in the string, matching the whole word or sequence of words.
TODO: Add a parameter to make it possible to do a case-insensitive match?
public static FindWordFormInString ( ITsString wordFormTss, ITsString sourceTss, ILgWritingSystemFactory wsf, int &ichMin, int &ichLim ) : bool
wordFormTss ITsString text of word form to look for
sourceTss ITsString text to search in
wsf ILgWritingSystemFactory source of char prop engines
ichMin int The start of the string where the text was found (undefined if /// this method returns false)
ichLim int The limit (one character position past the end) of the string /// where the text was found (undefined if this method returns false)
return bool

GetCharPropEngineAtOffset() public static method

Get the character property engine that should be used for interpreting the character at ich.
public static GetCharPropEngineAtOffset ( ITsString tss, ILgWritingSystemFactory wsf, int ich ) : ILgCharacterPropertyEngine
tss ITsString
wsf ILgWritingSystemFactory
ich int
return ILgCharacterPropertyEngine

GetCleanSingleRunTsString() public static method

Gets a TsString made from the ashes of the input parameter which has: 1) only one run 2) uses the ws of the 1st run of the input TsString.
public static GetCleanSingleRunTsString ( ITsString tss ) : ITsString
tss ITsString structured text string
return ITsString

GetCleanTextFromTsString() public static method

Get the text from a ITsString, removing ORCs and any text in the specified character styles. Also trims any non-wordforming characters from the beginning and the end of the text.
public static GetCleanTextFromTsString ( ITsString tss, IEnumerable stylesToRemove, bool fStopOnRemovedStyle, ILgWritingSystemFactory writingSystemFactory ) : string
tss ITsString structured text string
stylesToRemove IEnumerable List of styles to remove (null if no styles should be /// removed).
fStopOnRemovedStyle bool if set to true stop building the string /// when a style to remove is encountered and we have some text in the string; /// false to just skip stylesToRemove.
writingSystemFactory ILgWritingSystemFactory The writing system factory.
return string

GetCleanTsString() public static method

Gets a TsString with no: 1) ORCs corresponding to special runs, or 2) clipboard- style footnote or picture runs.
public static GetCleanTsString ( ITsString tss ) : ITsString
tss ITsString structured text string
return ITsString

GetCleanTsString() public static method

Gets a TsString with no: 1) leading and trailing spaces, 2) ORCs, 3) clipboard-style footnote runs, or 4) runs having the specified character styles.
public static GetCleanTsString ( ITsString tss, IEnumerable stylesToRemove ) : ITsString
tss ITsString structured text string to clean up
stylesToRemove IEnumerable List of styles to remove (null if no styles should be /// removed).
return ITsString

GetCleanTsString() public static method

Gets a TsString with no: 1) ORCs (except maybe unknown ones, if so requested), 3) clipboard-style footnote runs, or 4) runs having the specified character styles. Also, leading and trailing spaces are removed if requested.
public static GetCleanTsString ( ITsString tss, IEnumerable stylesToRemove, bool fStopOnRemovedStyle, bool fPreserveUnknownOrcs, bool fTrimSpaces ) : ITsString
tss ITsString structured text string to clean up
stylesToRemove IEnumerable List of styles to remove (null if no styles should be /// removed).
fStopOnRemovedStyle bool if set to true stop building the string /// when a style to remove is encountered and we have some text in the string; /// false to just skip stylesToRemove.
fPreserveUnknownOrcs bool true to allow the returned string to /// contain ORC characters not associated with a special run.
fTrimSpaces bool if set to true leading and trailing spaces are /// trimmed.
return ITsString

GetDiffsInTsStrings() public static method

Get an indication of the range of characters that differ between two TsStrings. Return null if they are equal If they are not, ichMin indicates the first different character (or the length of the shorter string). cvIns indicates how many characters must be inserted at ichMin, after deleting cvDel, to get tssNew. Character properties as well as values are considered. If it is ambiguous where the difference occurs, we first try to interpret the difference in a way that equates to inserting or deleting a complete word, otherwise, prefer to find the longest common string at the start.
public static GetDiffsInTsStrings ( ITsString tssOld, ITsString tssNew ) : TsStringDiffInfo
tssOld ITsString
tssNew ITsString
return TsStringDiffInfo

GetFirstVernacularWs() public static method

Gets the first vernacular ws.
public static GetFirstVernacularWs ( string vernWsVecImage, ILgWritingSystemFactory wsf, ITsString text ) : int
vernWsVecImage string The vern ws vec image, like "seh pt mar-fonipa".
wsf ILgWritingSystemFactory The Writing System Factory.
text ITsString The text.
return int

GetGuidFromProps() public static method

Get a Guid from the given text props.
public static GetGuidFromProps ( ITsTextProps ttp, FwObjDataTypes desiredOrcTypes, FwObjDataTypes &odt ) : System.Guid
ttp ITsTextProps The text props
desiredOrcTypes FwObjDataTypes Set of ORC types that we're interested in, dude; or /// null if it don't make no difference
odt FwObjDataTypes Actual object type
return System.Guid

GetGuidFromRun() public static method

Get a Guid from the given run in a structured text string.
public static GetGuidFromRun ( ITsString tss, int iRun ) : System.Guid
tss ITsString given structured text string
iRun int given run
return System.Guid

GetGuidFromRun() public static method

Get a Guid from the given run in a structured text string.
public static GetGuidFromRun ( ITsString tss, int iRun, FwObjDataTypes desiredOrcType ) : System.Guid
tss ITsString given structured text string
iRun int given run
desiredOrcType FwObjDataTypes The desired ORC type
return System.Guid

GetGuidFromRun() public static method

Get a Guid from the given run in a structured text string.
public static GetGuidFromRun ( ITsString tss, int iRun, FwObjDataTypes &odt, TsRunInfo &tri, ITsTextProps &ttp, FwObjDataTypes desiredOrcTypes ) : System.Guid
tss ITsString given structured text string
iRun int given run
odt FwObjDataTypes object data type, 0 if no ORC guid located
tri TsRunInfo run information
ttp ITsTextProps text properties of the run
desiredOrcTypes FwObjDataTypes The desired ORC types, or null to return any type of /// ORC
return System.Guid

GetGuidFromRun() public static method

Get a Guid from the given run in a structured text string.
public static GetGuidFromRun ( ITsString tss, int iRun, ITsTextProps ttp ) : System.Guid
tss ITsString given structured text string
iRun int given run
ttp ITsTextProps text properties of the run
return System.Guid

GetGuidFromRun() public static method

Get a Guid from the given run in a structured text string.
public static GetGuidFromRun ( ITsString tss, int iRun, TsRunInfo &tri, ITsTextProps &ttp ) : System.Guid
tss ITsString given structured text string
iRun int given run
tri TsRunInfo run information
ttp ITsTextProps text properties of the run
return System.Guid

GetHotGuidFromObjData() public static method

See if the string, typically obtained from a TsTextProps string property (int)FwTextPropType.ktptObjData, represents a hot link. If so, return the GUID of the object linked to. This overlaps some of the functionality of GetGuidFromProps and GetHotObjectGuidFromProps, for performance reasons.
public static GetHotGuidFromObjData ( string sObjData ) : System.Guid
sObjData string The s obj data.
return System.Guid

GetHotObjectGuidFromProps() public static method

Get a "Hot" Guid from the given text props.
public static GetHotObjectGuidFromProps ( ITsTextProps ttp ) : System.Guid
ttp ITsTextProps The text props
return System.Guid

GetObjData() public static method

Get the string to pass as ObjData property
public static GetObjData ( System.Guid guid, byte objectDataType ) : byte[]
guid System.Guid GUID of the data
objectDataType byte Type of object (e.g. kodtNameGuidHot).
return byte[]

GetOwnedGuidFromRun() public static method

Get an owned Guid from the given run in a structured text string.
public static GetOwnedGuidFromRun ( ITsString tss, int iRun, FwObjDataTypes &odt ) : System.Guid
tss ITsString given structured text string
iRun int given run
odt FwObjDataTypes object data type, 0 if no owned guid located
return System.Guid

GetOwnedGuidFromRun() public static method

Get an owned Guid from the given run in a structured text string.
public static GetOwnedGuidFromRun ( ITsString tss, int iRun, FwObjDataTypes &odt, TsRunInfo &tri, ITsTextProps &ttp ) : System.Guid
tss ITsString given structured text string
iRun int given run
odt FwObjDataTypes object data type, 0 if no owned guid located
tri TsRunInfo run information
ttp ITsTextProps text properties of the run
return System.Guid

GetOwnedORCs() public static method

Gets the owned ORCs from the given ITsString.
public static GetOwnedORCs ( ITsString tss ) : ITsString
tss ITsString The given ITsString.
return ITsString

GetTextProps() public static method

Convert XML (produced by the above 'GetString' method) into an ITsTextProps.
public static GetTextProps ( System.Xml.Linq.XElement xml, ILgWritingSystemFactory wsf ) : ITsTextProps
xml System.Xml.Linq.XElement The XML.
wsf ILgWritingSystemFactory The WSF.
return ITsTextProps

GetURL() public static method

Gets the URL information in a form suitable for writing out in an .
public static GetURL ( string sProp ) : string
sProp string The string property containing the URL info.
return string

GetUsefulGuidFromProps() public static method

Get a Guid from the given text props if the object type is a footnote or a picture.
public static GetUsefulGuidFromProps ( ITsTextProps ttp ) : System.Guid
ttp ITsTextProps The text props
return System.Guid

GetWritingSystems() public static method

Return a list of the writing systems found in the string.
public static GetWritingSystems ( ITsString tss ) : List
tss ITsString
return List

GetWsAtOffset() public static method

Get the ws at the given (ich) char offset in the tss.
public static GetWsAtOffset ( ITsString tss, int ich ) : int
tss ITsString The TSS.
ich int char offset
return int

GetWsOfRun() public static method

Get the writing system of the specified run of a TsString.
public static GetWsOfRun ( ITsString tss, int irun ) : int
tss ITsString
irun int
return int

GetXmlRep() public static method

Get an XML representation of the given ITsString.
public static GetXmlRep ( ITsString tss, ILgWritingSystemFactory wsf, int ws ) : string
tss ITsString The ITsString object
wsf ILgWritingSystemFactory Writing system factory so that we can convert writing system /// integer codes (which are database object ids) to the corresponding strings.
ws int If nonzero, the writing system for a multilingual string (<AStr>). /// If zero, then this is a monolingual string (<Str>).
return string

GetXmlRep() public static method

Get an XML representation of the given ITsString.
public static GetXmlRep ( ITsString tss, ILgWritingSystemFactory wsf, int ws, bool fWriteObjData ) : string
tss ITsString The ITsString object
wsf ILgWritingSystemFactory Writing system factory so that we can convert writing system /// integer codes (which are database object ids) to the corresponding strings.
ws int If nonzero, the writing system for a multilingual string (<AStr>). /// If zero, then this is a monolingual string (<Str>).
fWriteObjData bool If true, then write out embedded pictures and links. If false, ignore /// any runs that contain such objects.
return string

GetXmlRep() public static method

Get an XML representation of the given ITsTextProps.
public static GetXmlRep ( ITsTextProps ttp, ILgWritingSystemFactory wsf ) : string
ttp ITsTextProps The TTP.
wsf ILgWritingSystemFactory The WSF.
return string

InitIcuDataDir() public static method

Initialize the ICU Data directory based on the ICU data directory. It is safe to call this static method more than once, but necessary only to call it at least once.
public static InitIcuDataDir ( ) : void
return void

InsertOrcIntoPara() public static method

Insert (or replace) an ORC run in a string builder.
public static InsertOrcIntoPara ( System.Guid guid, FwObjDataTypes objDataType, ITsStrBldr tsStrBldr, int ichMin, int ichLim, int ws ) : void
guid System.Guid The GUID representing the embedded object
objDataType FwObjDataTypes The type of embedding
tsStrBldr ITsStrBldr The TS string builder
ichMin int The position at which the object is to be inserted
ichLim int If replacing an existing ORC (or other text), this is the Lim /// position (otherwise, should be set equal to ichMin)
ws int The ID of the writing system to use for the inserted run, or 0 /// to leave unspecified
return void

IsCharacterDefined() public static method

Determines whether or not the specified character is defined in ICU.
public static IsCharacterDefined ( string chr ) : bool
chr string
return bool

IsEndOfSentenceChar() public static method

Determines whether the given character is used to end a sentence.
public static IsEndOfSentenceChar ( int ch, LgGeneralCharCategory cc ) : bool
ch int The character.
cc LgGeneralCharCategory The general character category.
return bool

IsHyperlink() public static method

Checks to see if the text properties are for a hyperlink.
public static IsHyperlink ( ITsTextProps ttp ) : bool
ttp ITsTextProps The text properties.
return bool

IsValidChar() public static method

Determines whether the specified string is a valid string consisting of exactly one initial base character followed by zero or more legally placed combining marks.
public static IsValidChar ( string chr, ILgCharacterPropertyEngine cpe ) : bool
chr string The string to check.
cpe ILgCharacterPropertyEngine The character property engine.
return bool

IsWhite() public static method

Tells whether the full character (starting) at ich is a white-space character.
public static IsWhite ( ILgCharacterPropertyEngine cpe, string text, int ich ) : bool
cpe ILgCharacterPropertyEngine The character property engine.
text string The text.
ich int The character index.
return bool

MakeTss() public static method

Create an ITsString in the given writing system.
public static MakeTss ( ITsStrFactory tsf, int wsHvo, string text ) : ITsString
tsf ITsStrFactory
wsHvo int
text string
return ITsString

MakeTss() public static method

Create a new Tss based on the given string and ws.
public static MakeTss ( string src, int ws ) : ITsString
src string
ws int
return ITsString

MakeTss() public static method

Create an ITsString in the given writing system and with the given style name.
public static MakeTss ( string text, int wsHvo, string styleName ) : ITsString
text string
wsHvo int
styleName string
return ITsString

MergeString() public static method

Merges the string.
public static MergeString ( ITsString source, ITsString dest ) : ITsString
source ITsString The source.
dest ITsString The dest.
return ITsString

MergeString() public static method

Merges the string.
public static MergeString ( ITsString source, ITsString dest, bool fConcatenateIfBoth ) : ITsString
source ITsString The source.
dest ITsString The dest.
fConcatenateIfBoth bool If true, and if source and dest both have values that are not /// equal, concatenate source on end of dest. Otherwise ignore source if dest has a value.
return ITsString

NormalizeNfd() public static method

Normalizes the specified TsString in NFD form.
public static NormalizeNfd ( ITsString source ) : ITsString
source ITsString The TsString to normalize.
return ITsString

NormalizeNfd() public static method

Returns a string an NFD (normalized form, decomposed) form of a Unicode string. Enhance JohnT: This is not a very efficient implementation; we should be able to use some ICU method directly (as the ITsString implementation does). Fix if ever used for something high-performance!
public static NormalizeNfd ( string source ) : string
source string String to compose.
return string

NormalizeToNFC() public static method

Normalize the string for display. Uniscribe requires NFC. (See LT-4202 and LT-4203.)
public static NormalizeToNFC ( string s ) : string
s string
return string

ParseCharString() public static method

Parses the specified string into a list of characters, ignoring any bogus characters (digraphs, undefined Unicode characters, lone diacritics, etc.). The unparsed list is a string of valid characters delimited with the specified delimiter.
public static ParseCharString ( string chars, string delimiter, ILgCharacterPropertyEngine cpe ) : List
chars string The string containing a delimited list of characters.
delimiter string The delimiter (passed as a string, but really just a single /// character).
cpe ILgCharacterPropertyEngine The character property engine.
return List

ParseCharString() public static method

Parses the specified string into a list of characters. The unparsed list is a string of valid characters delimited with the specified delimiter.
public static ParseCharString ( string chars, string delimiter, ILgCharacterPropertyEngine cpe, List &invalidCharacters ) : List
chars string The string containing a delimited list of characters.
delimiter string The delimiter (passed as a string, but really just a single /// character).
cpe ILgCharacterPropertyEngine The character property engine.
invalidCharacters List The invalid characters.
return List

PropsForWs() public static method

Answer a TsTextProps that specifies the given writing system (all other props have default values).
public static PropsForWs ( int ws ) : ITsTextProps
ws int
return ITsTextProps

ReassignTss() public static method

Releases a tss string that was created with MakeString, before reassigning it. Especially useful in Dispose, since we check whether it is null before doing the release.
public static ReassignTss ( ITsString &tss, ITsString tssNewValue ) : void
tss ITsString tss to reassign a value to
tssNewValue ITsString the new tss value (including null)
return void

RemoveIllegalXmlChars() public static method

Remove characters that are illegal in XML files. Returns the input string if nothing is wrong with it.
public static RemoveIllegalXmlChars ( ITsString input ) : ITsString
input ITsString
return ITsString

RemoveIntProp() public static method

Removes the specified integer property from a Structured text string.
public static RemoveIntProp ( ITsString tss, int intProp ) : ITsString
tss ITsString The structured text string.
intProp int integer property to remove from the tss.
return ITsString

ReverseString() public static method

Reverse the order of characters within the string (make a mirror image of it). The tricky part, as always with UTF-16, is handling surrogate pairs correctly. TODO: Ideally this method should be in SilUtils.StringUtils. However, this method depends on the Surrogates class which is defined in BasicUtils which we didn't want to move just for this one method.
public static ReverseString ( string s ) : string
s string
return string

Split() public static method

Split the ITsString into pieces separated by one of the strings in separator, and using the same options as String.Split().
public static Split ( ITsString tss, string separator, StringSplitOptions opt ) : List
tss ITsString
separator string
opt StringSplitOptions
return List

TrimNonWordFormingChars() public static method

Trim the leading AND trailing non-word forming characters.
public static TrimNonWordFormingChars ( ITsString untrimmedString, ILgWritingSystemFactory writingSystemFactory ) : ITsString
untrimmedString ITsString string that may contain non-word forming characters
writingSystemFactory ILgWritingSystemFactory The ws factory used to get character properties
return ITsString

TrimNonWordFormingChars() public static method

Trim the leading AND/OR trailing non-word forming characters.
public static TrimNonWordFormingChars ( ITsString tssInput, ILgWritingSystemFactory writingSystemFactory, bool fTrimLeading, bool fTrimTrailing ) : ITsString
tssInput ITsString string that may contain non-word forming characters
writingSystemFactory ILgWritingSystemFactory The ws factory used to get character properties
fTrimLeading bool if set to true trim leading characters.
fTrimTrailing bool if set to true trim trailing characters.
return ITsString

TurnOwnedOrcIntoUnownedOrc() public static method

Replaces the requested run of the given builder with an identical ORC but whose type is un-owned rather than owned. If the given run is not an ORC at all or is not owned, do nothing.
public static TurnOwnedOrcIntoUnownedOrc ( ITsStrBldr bldr, int irun ) : void
bldr ITsStrBldr
irun int
return void

ValidateCharacterSequence() public static method

Finds the first base character/combining diacritic combination and removes any remaining characters.
public static ValidateCharacterSequence ( string origChars, ILgCharacterPropertyEngine cpe ) : string
origChars string The original string of characters.
cpe ILgCharacterPropertyEngine The character property engine.
return string

WriteHref() public static method

Writes an href element to the XML writer if the given string property is of the proper type.
public static WriteHref ( int tpt, string sProp, XmlWriter writer ) : bool
tpt int The FwTextPropType (passed as an int - grr).
sProp string The string property.
writer System.Xml.XmlWriter The writer.
return bool

Property Details

kRegexUrl public_oe static_oe property

Regular expression used to check whether a string appears to be a URL (as opposed to a file path)
public static Regex,System.Text.RegularExpressions kRegexUrl
return System.Text.RegularExpressions.Regex