ObjFW
Instance Methods | Class Methods | List of all members
OFString Class Reference

A class for handling strings. More...

#import <ObjFW/OFString.h>

Inheritance diagram for OFString:
OFObject <OFCopying> <OFMutableCopying> <OFComparing> <OFSerialization> <OFJSONRepresentation> <OFMessagePackRepresentation> <OFObject> OFConstantString OFMutableString

Instance Methods

(id) - initWithUTF8String:
 Initializes an already allocated OFString from a UTF-8 encoded C string. More...
 
(id) - initWithUTF8String:length:
 Initializes an already allocated OFString from a UTF-8 encoded C string with the specified length. More...
 
(id) - initWithUTF8StringNoCopy:freeWhenDone:
 Initializes an already allocated OFString from an UTF-8 encoded C string without copying it, if possible. More...
 
(id) - initWithCString:encoding:
 Initializes an already allocated OFString from a C string with the specified encoding. More...
 
(id) - initWithCString:encoding:length:
 Initializes an already allocated OFString from a C string with the specified encoding and length. More...
 
(id) - initWithData:encoding:
 Initializes an already allocated OFString from OFData with the specified encoding. More...
 
(id) - initWithString:
 Initializes an already allocated OFString with another string. More...
 
(id) - initWithCharacters:length:
 Initializes an already allocated OFString with a Unicode string with the specified length. More...
 
(id) - initWithUTF16String:
 Initializes an already allocated OFString with a UTF-16 string. More...
 
(id) - initWithUTF16String:length:
 Initializes an already allocated OFString with a UTF-16 string with the specified length. More...
 
(id) - initWithUTF16String:byteOrder:
 Initializes an already allocated OFString with a UTF-16 string, assuming the specified byte order if no byte order mark is found. More...
 
(id) - initWithUTF16String:length:byteOrder:
 Initializes an already allocated OFString with a UTF-16 string with the specified length, assuming the specified byte order if no byte order mark is found. More...
 
(id) - initWithUTF32String:
 Initializes an already allocated OFString with a UTF-32 string. More...
 
(id) - initWithUTF32String:length:
 Initializes an already allocated OFString with a UTF-32 string with the specified length. More...
 
(id) - initWithUTF32String:byteOrder:
 Initializes an already allocated OFString with a UTF-32 string, assuming the specified byte order if no byte order mark is found. More...
 
(id) - initWithUTF32String:length:byteOrder:
 Initializes an already allocated OFString with a UTF-32 string with the specified length, assuming the specified byte order if no byte order mark is found. More...
 
(id) - initWithFormat:
 Initializes an already allocated OFString with a format string. More...
 
(id) - initWithFormat:arguments:
 Initializes an already allocated OFString with a format string. More...
 
(id) - initWithContentsOfFile:
 Initializes an already allocated OFString with the contents of the specified file in the specified encoding. More...
 
(id) - initWithContentsOfFile:encoding:
 Initializes an already allocated OFString with the contents of the specified file in the specified encoding. More...
 
(id) - initWithContentsOfURL:
 Initializes an already allocated OFString with the contents of the specified URL. More...
 
(id) - initWithContentsOfURL:encoding:
 Initializes an already allocated OFString with the contents of the specified URL in the specified encoding. More...
 
(size_t) - getCString:maxLength:encoding:
 Writes the OFString into the specified C string with the specified encoding. More...
 
(size_t) - getLossyCString:maxLength:encoding:
 Writes the OFString into the specified C string with the specified encoding, replacing characters that cannot be represented in the specified encoding with a question mark. More...
 
(const char *) - cStringWithEncoding:
 Returns the OFString as a C string in the specified encoding. More...
 
(const char *) - lossyCStringWithEncoding:
 Returns the OFString as a C string in the specified encoding, replacing characters that cannot be represented in the specified encoding with a question mark. More...
 
(const char *) - UTF8String
 Returns the OFString as a UTF-8 encoded C string. More...
 
(size_t) - length
 Returns the length of the string in Unicode codepoints. More...
 
(size_t) - cStringLengthWithEncoding:
 Returns the number of bytes the string needs in the specified encoding. More...
 
(size_t) - UTF8StringLength
 Returns the number of bytes the string needs in UTF-8 encoding. More...
 
(of_comparison_result_t- caseInsensitiveCompare:
 Compares the OFString to another OFString without caring about the case. More...
 
(of_unichar_t) - characterAtIndex:
 Returns the Unicode character at the specified index. More...
 
(void) - getCharacters:inRange:
 Copies the Unicode characters in the specified range to the specified buffer. More...
 
(of_range_t- rangeOfString:
 Returns the range of the first occurrence of the string. More...
 
(of_range_t- rangeOfString:options:
 Returns the range of the string. More...
 
(of_range_t- rangeOfString:options:range:
 Returns the range of the string in the specified range. More...
 
(bool) - containsString:
 Returns whether the string contains the specified string. More...
 
(OFString *) - substringWithRange:
 Creates a substring with the specified range. More...
 
(OFString *) - stringByAppendingString:
 Creates a new string by appending another string. More...
 
(OFString *) - stringByAppendingFormat:
 Creates a new string by appending the specified format. More...
 
(OFString *) - stringByAppendingFormat:arguments:
 Creates a new string by appending the specified format. More...
 
(OFString *) - stringByAppendingPathComponent:
 Creates a new string by appending a path component. More...
 
(OFString *) - stringByPrependingString:
 Creates a new string by prepending another string. More...
 
(OFString *) - stringByReplacingOccurrencesOfString:withString:
 Creates a new string by replacing the occurrences of the specified string with the specified replacement. More...
 
(OFString *) - stringByReplacingOccurrencesOfString:withString:options:range:
 Creates a new string by replacing the occurrences of the specified string in the specified range with the specified replacement. More...
 
(OFString *) - uppercaseString
 Returns the string in uppercase. More...
 
(OFString *) - lowercaseString
 Returns the string in lowercase. More...
 
(OFString *) - capitalizedString
 Returns the string capitalized. More...
 
(OFString *) - stringByDeletingLeadingWhitespaces
 Creates a new string by deleting leading whitespaces. More...
 
(OFString *) - stringByDeletingTrailingWhitespaces
 Creates a new string by deleting trailing whitespaces. More...
 
(OFString *) - stringByDeletingEnclosingWhitespaces
 Creates a new string by deleting leading and trailing whitespaces. More...
 
(bool) - hasPrefix:
 Checks whether the string has the specified prefix. More...
 
(bool) - hasSuffix:
 Checks whether the string has the specified suffix. More...
 
(OFArray *) - componentsSeparatedByString:
 Separates an OFString into an OFArray of OFStrings. More...
 
(OFArray *) - componentsSeparatedByString:options:
 Separates an OFString into an OFArray of OFStrings. More...
 
(OFArray *) - pathComponents
 Returns the components of the path. More...
 
(OFString *) - lastPathComponent
 Returns the last component of the path. More...
 
(OFString *) - pathExtension
 Returns the file extension of the path. More...
 
(OFString *) - stringByDeletingLastPathComponent
 Returns the directory name of the path. More...
 
(OFString *) - stringByDeletingPathExtension
 Returns a new string with the file extension of the path removed. More...
 
(OFString *) - stringByStandardizingPath
 Returns the path with relative sub paths resolved. More...
 
(OFString *) - stringByStandardizingURLPath
 Returns the URL path with relative sub paths resolved. More...
 
(intmax_t) - decimalValue
 Returns the decimal value of the string as an intmax_t. More...
 
(uintmax_t) - hexadecimalValue
 Returns the hexadecimal value of the string as an uintmax_t. More...
 
(uintmax_t) - octalValue
 Returns the octal value of the string as an uintmax_t. More...
 
(float) - floatValue
 Returns the float value of the string as a float. More...
 
(double) - doubleValue
 Returns the double value of the string as a double. More...
 
(const of_unichar_t *) - characters
 Returns the string as an array of Unicode characters. More...
 
(const char16_t *) - UTF16String
 Returns the string in UTF-16 encoding with native byte order. More...
 
(const char16_t *) - UTF16StringWithByteOrder:
 Returns the string in UTF-16 encoding with the specified byte order. More...
 
(size_t) - UTF16StringLength
 Returns the length of the string in UTF-16 characters. More...
 
(const char32_t *) - UTF32String
 Returns the string in UTF-32 encoding with native byte order. More...
 
(const char32_t *) - UTF32StringWithByteOrder:
 Returns the string in UTF-32 encoding with the specified byte order. More...
 
(OFData *) - dataWithEncoding:
 Returns the string as OFData with the specified encoding. More...
 
(OFString *) - decomposedStringWithCanonicalMapping
 Returns the string in Unicode Normalization Form D (NFD). More...
 
(OFString *) - decomposedStringWithCompatibilityMapping
 Returns the string in Unicode Normalization Form KD (NFKD). More...
 
(void) - writeToFile:
 Writes the string into the specified file using UTF-8 encoding. More...
 
(void) - writeToFile:encoding:
 Writes the string into the specified file using the specified encoding. More...
 
(void) - enumerateLinesUsingBlock:
 block The block to call for each line More...
 
(OFString *) - MD5Hash
 Returns the MD5 hash of the string as an autoreleased OFString. More...
 
(OFString *) - RIPEMD160Hash
 Returns the RIPEMD-160 hash of the string as an autoreleased OFString. More...
 
(OFString *) - SHA1Hash
 Returns the SHA-1 hash of the string as an autoreleased OFString. More...
 
(OFString *) - SHA224Hash
 Returns the SHA-224 hash of the string as an autoreleased OFString. More...
 
(OFString *) - SHA256Hash
 Returns the SHA-256 hash of the string as an autoreleased OFString. More...
 
(OFString *) - SHA384Hash
 Returns the SHA-384 hash of the string as an autoreleased OFString. More...
 
(OFString *) - SHA512Hash
 Returns the SHA-512 hash of the string as an autoreleased OFString. More...
 
(id) - JSONValue
 Creates an object from the JSON value of the string. More...
 
(id) - JSONValueWithDepthLimit:
 Creates an object from the JSON value of the string. More...
 
(id) - objectByDeserializing
 Deserializes the receiver into an object. More...
 
(OFString *) - stringByURLEncoding
 Encodes a string for use in a URL. More...
 
(OFString *) - stringByURLEncodingWithAllowedCharacters:
 Encodes a string for use in a URL, but does not escape the specified ignored characters. More...
 
(OFString *) - stringByURLDecoding
 Decodes a string used in a URL. More...
 
(OFString *) - stringByXMLEscaping
 Escapes a string for use in an XML document. More...
 
(OFString *) - stringByXMLUnescaping
 Unescapes XML in the string.
 
(OFString *) - stringByXMLUnescapingWithDelegate:
 Unescapes XML in the string and uses the specified delegate for unknown entities. More...
 
(OFString *) - stringByXMLUnescapingWithBlock:
 Unescapes XML in the string and uses the specified block for unknown entities. More...
 
- Instance Methods inherited from OFObject
(id) - init
 Initializes an already allocated object. More...
 
(OFString *) - className
 Returns the name of the object's class. More...
 
(OFString *) - description
 Returns a description for the object. More...
 
(nullable void *) - allocMemoryWithSize:
 Allocates memory and stores it in the object's memory pool. More...
 
(nullable void *) - allocMemoryWithSize:count:
 Allocates memory for the specified number of items and stores it in the object's memory pool. More...
 
(nullable void *) - resizeMemory:size:
 Resizes memory in the object's memory pool to the specified size. More...
 
(nullable void *) - resizeMemory:size:count:
 Resizes memory in the object's memory pool to the specific number of items of the specified size. More...
 
(void) - freeMemory:
 Frees allocated memory and removes it from the object's memory pool. More...
 
(void) - dealloc
 Deallocates the object. More...
 
(void) - performSelector:afterDelay:
 Performs the specified selector after the specified delay. More...
 
(void) - performSelector:withObject:afterDelay:
 Performs the specified selector with the specified object after the specified delay. More...
 
(void) - performSelector:withObject:withObject:afterDelay:
 Performs the specified selector with the specified objects after the specified delay. More...
 
(void) - performSelector:onThread:waitUntilDone:
 Performs the specified selector on the specified thread. More...
 
(void) - performSelector:onThread:withObject:waitUntilDone:
 Performs the specified selector on the specified thread with the specified object. More...
 
(void) - performSelector:onThread:withObject:withObject:waitUntilDone:
 Performs the specified selector on the specified thread with the specified objects. More...
 
(void) - performSelectorOnMainThread:waitUntilDone:
 Performs the specified selector on the main thread. More...
 
(void) - performSelectorOnMainThread:withObject:waitUntilDone:
 Performs the specified selector on the main thread with the specified object. More...
 
(void) - performSelectorOnMainThread:withObject:withObject:waitUntilDone:
 Performs the specified selector on the main thread with the specified objects. More...
 
(void) - performSelector:onThread:afterDelay:
 Performs the specified selector on the specified thread after the specified delay. More...
 
(void) - performSelector:onThread:withObject:afterDelay:
 Performs the specified selector on the specified thread with the specified object after the specified delay. More...
 
(void) - performSelector:onThread:withObject:withObject:afterDelay:
 Performs the specified selector on the specified thread with the specified objects after the specified delay. More...
 
(nullable id) - forwardingTargetForSelector:
 This method is called when resolveClassMethod: or resolveInstanceMethod: returned false. It should return a target to which the message should be forwarded. More...
 
(void) - doesNotRecognizeSelector:
 Handles messages which are not understood by the receiver. More...
 
(OFString *) - stringBySerializing
 Creates a string by serializing the receiver. More...
 
- Instance Methods inherited from <OFObject>
(bool) - isKindOfClass:
 Returns a boolean whether the object of the specified kind. More...
 
(bool) - isMemberOfClass:
 Returns a boolean whether the object is a member of the specified class. More...
 
(bool) - respondsToSelector:
 Returns a boolean whether the object responds to the specified selector. More...
 
(nullable IMP) - methodForSelector:
 Returns the implementation for the specified selector. More...
 
(nullable const char *) - typeEncodingForSelector:
 Returns the type encoding for the specified selector. More...
 
(nullable id) - performSelector:
 Performs the specified selector. More...
 
(nullable id) - performSelector:withObject:
 Performs the specified selector with the specified object. More...
 
(nullable id) - performSelector:withObject:withObject:
 Performs the specified selector with the specified objects. More...
 
(bool) - isEqual:
 Checks two objects for equality. More...
 
(uint32_t) - hash
 Calculates a hash for the object. More...
 
(id) - retain
 Increases the retain count. More...
 
(unsigned int) - retainCount
 Returns the retain count. More...
 
(void) - release
 Decreases the retain count. More...
 
(id) - autorelease
 Adds the object to the topmost OFAutoreleasePool of the thread's autorelease pool stack. More...
 
(id) - self
 Returns the receiver. More...
 
(bool) - isProxy
 Returns whether the object is a proxy object. More...
 
(bool) - allowsWeakReference
 Returns whether the class allows weak references. More...
 
(bool) - retainWeakReference
 Retain a weak reference to this object. More...
 
- Instance Methods inherited from <OFCopying>
(id) - copy
 Copies the object. More...
 
- Instance Methods inherited from <OFMutableCopying>
(id) - mutableCopy
 Creates a mutable copy of the object. More...
 
- Instance Methods inherited from <OFSerialization>
(id) - initWithSerialization:
 Initializes the object with the specified XML element serialization. More...
 
(OFXMLElement *) - XMLElementBySerializing
 Serializes the object into an XML element. More...
 
- Instance Methods inherited from <OFJSONRepresentation>
(OFString *) - JSONRepresentation
 Returns the JSON representation of the object as a string. More...
 
(OFString *) - JSONRepresentationWithOptions:
 Returns the JSON representation of the object as a string. More...
 
- Instance Methods inherited from <OFMessagePackRepresentation>
(OFData *) - messagePackRepresentation
 Returns the MessagePack representation of the object as OFData. More...
 

Class Methods

(instancetype) + string
 Creates a new OFString. More...
 
(instancetype) + stringWithUTF8String:
 Creates a new OFString from a UTF-8 encoded C string. More...
 
(instancetype) + stringWithUTF8String:length:
 Creates a new OFString from a UTF-8 encoded C string with the specified length. More...
 
(instancetype) + stringWithUTF8StringNoCopy:freeWhenDone:
 Creates a new OFString from a UTF-8 encoded C string without copying the string. More...
 
(instancetype) + stringWithCString:encoding:
 Creates a new OFString from a C string with the specified encoding. More...
 
(instancetype) + stringWithCString:encoding:length:
 Creates a new OFString from a C string with the specified encoding and length. More...
 
(instancetype) + stringWithData:encoding:
 Creates a new OFString from OFData with the specified encoding. More...
 
(instancetype) + stringWithString:
 Creates a new OFString from another string. More...
 
(instancetype) + stringWithCharacters:length:
 Creates a new OFString from a Unicode string with the specified length. More...
 
(instancetype) + stringWithUTF16String:
 Creates a new OFString from a UTF-16 encoded string. More...
 
(instancetype) + stringWithUTF16String:length:
 Creates a new OFString from a UTF-16 encoded string with the specified length. More...
 
(instancetype) + stringWithUTF16String:byteOrder:
 Creates a new OFString from a UTF-16 encoded string, assuming the specified byte order if no byte order mark is found. More...
 
(instancetype) + stringWithUTF16String:length:byteOrder:
 Creates a new OFString from a UTF-16 encoded string with the specified length, assuming the specified byte order if no byte order mark is found. More...
 
(instancetype) + stringWithUTF32String:
 Creates a new OFString from a UTF-32 encoded string. More...
 
(instancetype) + stringWithUTF32String:length:
 Creates a new OFString from a UTF-32 encoded string with the specified length. More...
 
(instancetype) + stringWithUTF32String:byteOrder:
 Creates a new OFString from a UTF-32 encoded string, assuming the specified byte order if no byte order mark is found. More...
 
(instancetype) + stringWithUTF32String:length:byteOrder:
 Creates a new OFString from a UTF-32 encoded string with the specified length, assuming the specified byte order if no byte order mark is found. More...
 
(instancetype) + stringWithFormat:
 Creates a new OFString from a format string. More...
 
(instancetype) + stringWithContentsOfFile:
 Creates a new OFString with the contents of the specified UTF-8 encoded file. More...
 
(instancetype) + stringWithContentsOfFile:encoding:
 Creates a new OFString with the contents of the specified file in the specified encoding. More...
 
(instancetype) + stringWithContentsOfURL:
 Creates a new OFString with the contents of the specified URL. More...
 
(instancetype) + stringWithContentsOfURL:encoding:
 Creates a new OFString with the contents of the specified URL in the specified encoding. More...
 
(OFString *) + pathWithComponents:
 Creates a path from the specified path components. More...
 
- Class Methods inherited from OFObject
(void) + load
 A method which is called once when the class is loaded into the runtime. More...
 
(void) + unload
 A method which is called when the class is unloaded from the runtime. More...
 
(void) + initialize
 A method which is called the moment before the first call to the class is being made. More...
 
(id) + alloc
 Allocates memory for an instance of the class and sets up the memory pool for the object. More...
 
(id) + new
 Allocates memory for a new instance and calls init on it. More...
 
(Class) + class
 Returns the class. More...
 
(OFString *) + className
 Returns the name of the class as a string. More...
 
(bool) + isSubclassOfClass:
 Returns a boolean whether the class is a subclass of the specified class. More...
 
(nullable Class) + superclass
 Returns the superclass of the class. More...
 
(bool) + instancesRespondToSelector:
 Checks whether instances of the class respond to a given selector. More...
 
(bool) + conformsToProtocol:
 Checks whether the class conforms to a given protocol. More...
 
(nullable IMP) + instanceMethodForSelector:
 Returns the implementation of the instance method for the specified selector. More...
 
(nullable const char *) + typeEncodingForInstanceSelector:
 Returns the type encoding of the instance method for the specified selector. More...
 
(OFString *) + description
 Returns a description for the class, which is usually the class name. More...
 
(nullable IMP) + replaceClassMethod:withMethodFromClass:
 Replaces a class method with a class method from another class. More...
 
(nullable IMP) + replaceInstanceMethod:withMethodFromClass:
 Replaces an instance method with an instance method from another class. More...
 
(nullable IMP) + replaceClassMethod:withImplementation:typeEncoding:
 Replaces or adds a class method. More...
 
(nullable IMP) + replaceInstanceMethod:withImplementation:typeEncoding:
 Replaces or adds an instance method. More...
 
(void) + inheritMethodsFromClass:
 Adds all methods from the specified class to the class that is the receiver. More...
 
(BOOL) + resolveClassMethod:
 Try to resolve the specified class method. More...
 
(BOOL) + resolveInstanceMethod:
 Try to resolve the specified instance method. More...
 
(id) + copy
 Returns the class. More...
 

Detailed Description

A class for handling strings.

Method Documentation

◆ capitalizedString()

- (OFString *) capitalizedString

Returns the string capitalized.

Note
This only considers spaces, tabs and newlines to be word delimiters! Also note that this might change in the future to all word delimiters specified by Unicode!
Returns
The capitalized string

◆ caseInsensitiveCompare:()

- (of_comparison_result_t) caseInsensitiveCompare: (OFString *)  otherString

Compares the OFString to another OFString without caring about the case.

Parameters
otherStringA string to compare with
Returns
An of_comparison_result_t

◆ characterAtIndex:()

- (of_unichar_t) characterAtIndex: (size_t)  index

Returns the Unicode character at the specified index.

Parameters
indexThe index of the Unicode character to return
Returns
The Unicode character at the specified index

◆ characters()

- (const of_unichar_t *) characters

Returns the string as an array of Unicode characters.

The result is valid until the autorelease pool is released. If you want to use the result outside the scope of the current autorelease pool, you have to copy it.

Returns
The string as an array of Unicode characters

◆ componentsSeparatedByString:()

- (OFArray *) componentsSeparatedByString: (OFString *)  delimiter

Separates an OFString into an OFArray of OFStrings.

Parameters
delimiterThe delimiter for separating
Returns
An autoreleased OFArray with the separated string

◆ componentsSeparatedByString:options:()

- (OFArray *) componentsSeparatedByString: (OFString *)  delimiter
options: (int)  options 

Separates an OFString into an OFArray of OFStrings.

Parameters
delimiterThe delimiter for separating
optionsOptions according to which the string should be separated.
Possible values are:
Value Description
OF_STRING_SKIP_EMPTY Skip empty components
Returns
An autoreleased OFArray with the separated string

◆ containsString:()

- (bool) containsString: (OFString *)  string

Returns whether the string contains the specified string.

Parameters
stringThe string to search
Returns
Whether the string contains the specified string

◆ cStringLengthWithEncoding:()

- (size_t) cStringLengthWithEncoding: (of_string_encoding_t encoding

Returns the number of bytes the string needs in the specified encoding.

Parameters
encodingThe encoding for the string
Returns
The number of bytes the string needs in the specified encoding.

◆ cStringWithEncoding:()

- (const char *) cStringWithEncoding: (of_string_encoding_t encoding

Returns the OFString as a C string in the specified encoding.

The result is valid until the autorelease pool is released. If you want to use the result outside the scope of the current autorelease pool, you have to copy it.

Parameters
encodingThe encoding for the C string
Returns
The OFString as a C string in the specified encoding

◆ dataWithEncoding:()

- (OFData *) dataWithEncoding: (of_string_encoding_t encoding

Returns the string as OFData with the specified encoding.

Parameters
encodingThe encoding to use for the returned OFData
Returns
The string as OFData with the specified encoding

◆ decimalValue()

- (intmax_t) decimalValue

Returns the decimal value of the string as an intmax_t.

Leading and trailing whitespaces are ignored.

If the string contains any non-number characters, an OFInvalidEncodingException is thrown.

If the number is too big to fit into an intmax_t, an OFOutOfRangeException is thrown.

Returns
An intmax_t with the value of the string

◆ decomposedStringWithCanonicalMapping()

- (OFString *) decomposedStringWithCanonicalMapping

Returns the string in Unicode Normalization Form D (NFD).

Returns
The string in Unicode Normalization Form D (NFD)

◆ decomposedStringWithCompatibilityMapping()

- (OFString *) decomposedStringWithCompatibilityMapping

Returns the string in Unicode Normalization Form KD (NFKD).

Returns
The string in Unicode Normalization Form KD (NFKD)

◆ doubleValue()

- (double) doubleValue

Returns the double value of the string as a double.

If the string contains any non-number characters, an OFInvalidEncodingException is thrown.

Returns
A double with the value of the string

◆ enumerateLinesUsingBlock:()

- (void) enumerateLinesUsingBlock: (of_string_line_enumeration_block_t block

block The block to call for each line

Enumerates all lines in the receiver using the specified block.

◆ floatValue()

- (float) floatValue

Returns the float value of the string as a float.

If the string contains any non-number characters, an OFInvalidEncodingException is thrown.

Returns
A float with the value of the string

◆ getCharacters:inRange:()

- (void) getCharacters: (of_unichar_t *)  buffer
inRange: (of_range_t range 

Copies the Unicode characters in the specified range to the specified buffer.

Parameters
bufferThe buffer to store the Unicode characters
rangeThe range of the Unicode characters to copy

◆ getCString:maxLength:encoding:()

- (size_t) getCString: (char *)  cString
maxLength: (size_t)  maxLength
encoding: (of_string_encoding_t encoding 

Writes the OFString into the specified C string with the specified encoding.

Parameters
cStringThe C string to write into
maxLengthThe maximum number of bytes to write into the C string, including the terminating zero
encodingThe encoding to use for writing into the C string
Returns
The number of bytes written into the C string, without the terminating zero

◆ getLossyCString:maxLength:encoding:()

- (size_t) getLossyCString: (char *)  cString
maxLength: (size_t)  maxLength
encoding: (of_string_encoding_t encoding 

Writes the OFString into the specified C string with the specified encoding, replacing characters that cannot be represented in the specified encoding with a question mark.

Parameters
cStringThe C string to write into
maxLengthThe maximum number of bytes to write into the C string, including the terminating zero
encodingThe encoding to use for writing into the C string
Returns
The number of bytes written into the C string, without the terminating zero

◆ hasPrefix:()

- (bool) hasPrefix: (OFString *)  prefix

Checks whether the string has the specified prefix.

Parameters
prefixThe prefix to check for
Returns
A boolean whether the string has the specified prefix

◆ hasSuffix:()

- (bool) hasSuffix: (OFString *)  suffix

Checks whether the string has the specified suffix.

Parameters
suffixThe suffix to check for
Returns
A boolean whether the string has the specified suffix

◆ hexadecimalValue()

- (uintmax_t) hexadecimalValue

Returns the hexadecimal value of the string as an uintmax_t.

Leading and trailing whitespaces are ignored.

If the string contains any non-number characters, an OFInvalidEncodingException is thrown.

If the number is too big to fit into an uintmax_t, an OFOutOfRangeException is thrown.

Returns
A uintmax_t with the value of the string

◆ initWithCharacters:length:()

- (id) initWithCharacters: (const of_unichar_t *)  characters
length: (size_t)  length 

Initializes an already allocated OFString with a Unicode string with the specified length.

Parameters
charactersAn array of Unicode characters
lengthThe length of the Unicode character array
Returns
An initialized OFString

◆ initWithContentsOfFile:()

- (id) initWithContentsOfFile: (OFString *)  path

Initializes an already allocated OFString with the contents of the specified file in the specified encoding.

Parameters
pathThe path to the file
Returns
An initialized OFString

◆ initWithContentsOfFile:encoding:()

- (id) initWithContentsOfFile: (OFString *)  path
encoding: (of_string_encoding_t encoding 

Initializes an already allocated OFString with the contents of the specified file in the specified encoding.

Parameters
pathThe path to the file
encodingThe encoding of the file
Returns
An initialized OFString

◆ initWithContentsOfURL:()

- (id) initWithContentsOfURL: (OFURL *)  URL

Initializes an already allocated OFString with the contents of the specified URL.

If the URL's scheme is file, it tries UTF-8 encoding.

If the URL's scheme is http(s), it tries to detect the encoding from the HTTP headers. If it could not detect the encoding using the HTTP headers, it tries UTF-8.

Parameters
URLThe URL to the contents for the string
Returns
An initialized OFString

◆ initWithContentsOfURL:encoding:()

- (id) initWithContentsOfURL: (OFURL *)  URL
encoding: (of_string_encoding_t encoding 

Initializes an already allocated OFString with the contents of the specified URL in the specified encoding.

Parameters
URLThe URL to the contents for the string
encodingThe encoding to assume
Returns
An initialized OFString

◆ initWithCString:encoding:()

- (id) initWithCString: (const char *)  cString
encoding: (of_string_encoding_t encoding 

Initializes an already allocated OFString from a C string with the specified encoding.

Parameters
cStringA C string to initialize the OFString with
encodingThe encoding of the C string
Returns
An initialized OFString

◆ initWithCString:encoding:length:()

- (id) initWithCString: (const char *)  cString
encoding: (of_string_encoding_t encoding
length: (size_t)  cStringLength 

Initializes an already allocated OFString from a C string with the specified encoding and length.

Parameters
cStringA C string to initialize the OFString with
encodingThe encoding of the C string
cStringLengthThe length of the C string
Returns
An initialized OFString

◆ initWithData:encoding:()

- (id) initWithData: (OFData *)  data
encoding: (of_string_encoding_t encoding 

Initializes an already allocated OFString from OFData with the specified encoding.

Parameters
dataOFData with the contents of the string
encodingThe encoding in which the string is stored in the OFData
Returns
An initialized OFString

◆ initWithFormat:()

- (id) initWithFormat: (OFConstantString *)  format
,   ... 

Initializes an already allocated OFString with a format string.

See printf for the format syntax. As an addition, %@ is available as format specifier for objects, C for of_unichar_t and S for const of_unichar_t *.

Parameters
formatA string used as format to initialize the OFString
Returns
An initialized OFString

◆ initWithFormat:arguments:()

- (id) initWithFormat: (OFConstantString *)  format
arguments: (va_list)  arguments 

Initializes an already allocated OFString with a format string.

See printf for the format syntax. As an addition, %@ is available as format specifier for objects, C for of_unichar_t and S for const of_unichar_t *.

Parameters
formatA string used as format to initialize the OFString
argumentsThe arguments used in the format string
Returns
An initialized OFString

◆ initWithString:()

- (id) initWithString: (OFString *)  string

Initializes an already allocated OFString with another string.

Parameters
stringA string to initialize the OFString with
Returns
An initialized OFString

◆ initWithUTF16String:()

- (id) initWithUTF16String: (const char16_t *)  string

Initializes an already allocated OFString with a UTF-16 string.

Parameters
stringThe UTF-16 string
Returns
An initialized OFString

◆ initWithUTF16String:byteOrder:()

- (id) initWithUTF16String: (const char16_t *)  string
byteOrder: (of_byte_order_t byteOrder 

Initializes an already allocated OFString with a UTF-16 string, assuming the specified byte order if no byte order mark is found.

Parameters
stringThe UTF-16 string
byteOrderThe byte order to assume if there is no byte order mark
Returns
An initialized OFString

◆ initWithUTF16String:length:()

- (id) initWithUTF16String: (const char16_t *)  string
length: (size_t)  length 

Initializes an already allocated OFString with a UTF-16 string with the specified length.

Parameters
stringThe UTF-16 string
lengthThe length of the UTF-16 string
Returns
An initialized OFString

◆ initWithUTF16String:length:byteOrder:()

- (id) initWithUTF16String: (const char16_t *)  string
length: (size_t)  length
byteOrder: (of_byte_order_t byteOrder 

Initializes an already allocated OFString with a UTF-16 string with the specified length, assuming the specified byte order if no byte order mark is found.

Parameters
stringThe UTF-16 string
lengthThe length of the UTF-16 string
byteOrderThe byte order to assume if there is no byte order mark
Returns
An initialized OFString

◆ initWithUTF32String:()

- (id) initWithUTF32String: (const char32_t *)  string

Initializes an already allocated OFString with a UTF-32 string.

Parameters
stringThe UTF-32 string
Returns
An initialized OFString

◆ initWithUTF32String:byteOrder:()

- (id) initWithUTF32String: (const char32_t *)  string
byteOrder: (of_byte_order_t byteOrder 

Initializes an already allocated OFString with a UTF-32 string, assuming the specified byte order if no byte order mark is found.

Parameters
stringThe UTF-32 string
byteOrderThe byte order to assume if there is no byte order mark
Returns
An initialized OFString

◆ initWithUTF32String:length:()

- (id) initWithUTF32String: (const char32_t *)  string
length: (size_t)  length 

Initializes an already allocated OFString with a UTF-32 string with the specified length.

Parameters
stringThe UTF-32 string
lengthThe length of the UTF-32 string
Returns
An initialized OFString

◆ initWithUTF32String:length:byteOrder:()

- (id) initWithUTF32String: (const char32_t *)  string
length: (size_t)  length
byteOrder: (of_byte_order_t byteOrder 

Initializes an already allocated OFString with a UTF-32 string with the specified length, assuming the specified byte order if no byte order mark is found.

Parameters
stringThe UTF-32 string
lengthThe length of the UTF-32 string
byteOrderThe byte order to assume if there is no byte order mark
Returns
An initialized OFString

◆ initWithUTF8String:()

- (id) initWithUTF8String: (const char *)  UTF8String

Initializes an already allocated OFString from a UTF-8 encoded C string.

Parameters
UTF8StringA UTF-8 encoded C string to initialize the OFString with
Returns
An initialized OFString

◆ initWithUTF8String:length:()

- (id) initWithUTF8String: (const char *)  UTF8String
length: (size_t)  UTF8StringLength 

Initializes an already allocated OFString from a UTF-8 encoded C string with the specified length.

Parameters
UTF8StringA UTF-8 encoded C string to initialize the OFString with
UTF8StringLengthThe length of the UTF-8 encoded C string
Returns
An initialized OFString

◆ initWithUTF8StringNoCopy:freeWhenDone:()

- (id) initWithUTF8StringNoCopy: (char *)  UTF8String
freeWhenDone: (bool)  freeWhenDone 

Initializes an already allocated OFString from an UTF-8 encoded C string without copying it, if possible.

Note
Mutable versions always create a copy!
Parameters
UTF8StringA UTF-8 encoded C string to initialize the OFString with
freeWhenDoneWhether to free the C string when it is not needed anymore
Returns
An initialized OFString

◆ JSONValue()

- (id) JSONValue

Creates an object from the JSON value of the string.

Note
This also allows parsing JSON5, an extension of JSON. See http://json5.org/ for more details.
Warning
Although not specified by the JSON specification, this can also return primitives like strings and numbers. The rationale behind this is that most JSON parsers allow JSON data just consisting of a single primitive, leading to real world JSON files sometimes only consisting of a single primitive. Therefore, you should not make any assumptions about the object returned by this method if you don't want your program to terminate due to a message not understood, but instead check the returned object using isKindOfClass: (OFObject-p).
Returns
An object

◆ JSONValueWithDepthLimit:()

- (id) JSONValueWithDepthLimit: (size_t)  depthLimit

Creates an object from the JSON value of the string.

Note
This also allows parsing JSON5, an extension of JSON. See http://json5.org/ for more details.
Warning
Although not specified by the JSON specification, this can also return primitives like strings and numbers. The rationale behind this is that most JSON parsers allow JSON data just consisting of a single primitive, leading to real world JSON files sometimes only consisting of a single primitive. Therefore, you should not make any assumptions about the object returned by this method if you don't want your program to terminate due to a message not understood, but instead check the returned object using isKindOfClass: (OFObject-p).
Parameters
depthLimitThe maximum depth the parser should accept (defaults to 32 if not specified, 0 means no limit (insecure!))
Returns
An object

◆ lastPathComponent()

- (OFString *) lastPathComponent

Returns the last component of the path.

Returns
The last component of the path

◆ length()

- (size_t) length

Returns the length of the string in Unicode codepoints.

Returns
The length of the string in Unicode codepoints

◆ lossyCStringWithEncoding:()

- (const char *) lossyCStringWithEncoding: (of_string_encoding_t encoding

Returns the OFString as a C string in the specified encoding, replacing characters that cannot be represented in the specified encoding with a question mark.

The result is valid until the autorelease pool is released. If you want to use the result outside the scope of the current autorelease pool, you have to copy it.

Parameters
encodingThe encoding for the C string
Returns
The OFString as a C string in the specified encoding

◆ lowercaseString()

- (OFString *) lowercaseString

Returns the string in lowercase.

Returns
The string in lowercase

◆ MD5Hash()

- (OFString *) MD5Hash

Returns the MD5 hash of the string as an autoreleased OFString.

Returns
The MD5 hash of the string as an autoreleased OFString

◆ objectByDeserializing()

- (id) objectByDeserializing

Deserializes the receiver into an object.

Returns
The deserialized object

◆ octalValue()

- (uintmax_t) octalValue

Returns the octal value of the string as an uintmax_t.

Leading and trailing whitespaces are ignored.

If the string contains any non-number characters, an OFInvalidEncodingException is thrown.

If the number is too big to fit into an uintmax_t, an OFOutOfRangeException is thrown.

Returns
A uintmax_t with the value of the string

◆ pathComponents()

- (OFArray *) pathComponents

Returns the components of the path.

Returns
The components of the path

◆ pathExtension()

- (OFString *) pathExtension

Returns the file extension of the path.

Returns
The file extension of the path

◆ pathWithComponents:()

+ (OFString *) pathWithComponents: (OFArray *)  components

Creates a path from the specified path components.

Parameters
componentsAn array of components for the path
Returns
A new autoreleased OFString

◆ rangeOfString:()

- (of_range_t) rangeOfString: (OFString *)  string

Returns the range of the first occurrence of the string.

Parameters
stringThe string to search
Returns
The range of the first occurrence of the string or a range with OF_NOT_FOUND as start position if it was not found

◆ rangeOfString:options:()

- (of_range_t) rangeOfString: (OFString *)  string
options: (int)  options 

Returns the range of the string.

Parameters
stringThe string to search
optionsOptions modifying search behaviour.
Possible values are:
Value Description
OF_STRING_SEARCH_BACKWARDS Search backwards in the string
Returns
The range of the first occurrence of the string or a range with OF_NOT_FOUND as start position if it was not found

◆ rangeOfString:options:range:()

- (of_range_t) rangeOfString: (OFString *)  string
options: (int)  options
range: (of_range_t range 

Returns the range of the string in the specified range.

Parameters
stringThe string to search
optionsOptions modifying search behaviour.
Possible values are:
Value Description
OF_STRING_SEARCH_BACKWARDS Search backwards in the string
rangeThe range in which to search
Returns
The range of the first occurrence of the string or a range with OF_NOT_FOUND as start position if it was not found

◆ RIPEMD160Hash()

- (OFString *) RIPEMD160Hash

Returns the RIPEMD-160 hash of the string as an autoreleased OFString.

Returns
The RIPEMD-160 hash of the string as an autoreleased OFString

◆ SHA1Hash()

- (OFString *) SHA1Hash

Returns the SHA-1 hash of the string as an autoreleased OFString.

Returns
The SHA-1 hash of the string as an autoreleased OFString

◆ SHA224Hash()

- (OFString *) SHA224Hash

Returns the SHA-224 hash of the string as an autoreleased OFString.

Returns
The SHA-224 hash of the string as an autoreleased OFString

◆ SHA256Hash()

- (OFString *) SHA256Hash

Returns the SHA-256 hash of the string as an autoreleased OFString.

Returns
The SHA-256 hash of the string as an autoreleased OFString

◆ SHA384Hash()

- (OFString *) SHA384Hash

Returns the SHA-384 hash of the string as an autoreleased OFString.

Returns
The SHA-384 hash of the string as an autoreleased OFString

◆ SHA512Hash()

- (OFString *) SHA512Hash

Returns the SHA-512 hash of the string as an autoreleased OFString.

Returns
The SHA-512 hash of the string as an autoreleased OFString

◆ string()

+ (instancetype) string

Creates a new OFString.

Returns
A new, autoreleased OFString

◆ stringByAppendingFormat:()

- (OFString *) stringByAppendingFormat: (OFConstantString *)  format
,   ... 

Creates a new string by appending the specified format.

Parameters
formatA format string which generates the string to append
Returns
A new, autoreleased OFString with the specified format appended

◆ stringByAppendingFormat:arguments:()

- (OFString *) stringByAppendingFormat: (OFConstantString *)  format
arguments: (va_list)  arguments 

Creates a new string by appending the specified format.

Parameters
formatA format string which generates the string to append
argumentsThe arguments used in the format string
Returns
A new, autoreleased OFString with the specified format appended

◆ stringByAppendingPathComponent:()

- (OFString *) stringByAppendingPathComponent: (OFString *)  component

Creates a new string by appending a path component.

Parameters
componentThe path component to append
Returns
A new, autoreleased OFString with the path component appended

◆ stringByAppendingString:()

- (OFString *) stringByAppendingString: (OFString *)  string

Creates a new string by appending another string.

Parameters
stringThe string to append
Returns
A new, autoreleased OFString with the specified string appended

◆ stringByDeletingEnclosingWhitespaces()

- (OFString *) stringByDeletingEnclosingWhitespaces

Creates a new string by deleting leading and trailing whitespaces.

Returns
A new autoreleased OFString with leading and trailing whitespaces deleted

◆ stringByDeletingLastPathComponent()

- (OFString *) stringByDeletingLastPathComponent

Returns the directory name of the path.

Returns
The directory name of the path

◆ stringByDeletingLeadingWhitespaces()

- (OFString *) stringByDeletingLeadingWhitespaces

Creates a new string by deleting leading whitespaces.

Returns
A new autoreleased OFString with leading whitespaces deleted

◆ stringByDeletingPathExtension()

- (OFString *) stringByDeletingPathExtension

Returns a new string with the file extension of the path removed.

Returns
A new string with the file extension of the path removed

◆ stringByDeletingTrailingWhitespaces()

- (OFString *) stringByDeletingTrailingWhitespaces

Creates a new string by deleting trailing whitespaces.

Returns
A new autoreleased OFString with trailing whitespaces deleted

◆ stringByPrependingString:()

- (OFString *) stringByPrependingString: (OFString *)  string

Creates a new string by prepending another string.

Parameters
stringThe string to prepend
Returns
A new autoreleased OFString with the specified string prepended

◆ stringByReplacingOccurrencesOfString:withString:()

- (OFString *) stringByReplacingOccurrencesOfString: (OFString *)  string
withString: (OFString *)  replacement 

Creates a new string by replacing the occurrences of the specified string with the specified replacement.

Parameters
stringThe string to replace
replacementThe string with which it should be replaced
Returns
A new string with the occurrences of the specified string replaced

◆ stringByReplacingOccurrencesOfString:withString:options:range:()

- (OFString *) stringByReplacingOccurrencesOfString: (OFString *)  string
withString: (OFString *)  replacement
options: (int)  options
range: (of_range_t range 

Creates a new string by replacing the occurrences of the specified string in the specified range with the specified replacement.

Parameters
stringThe string to replace
replacementThe string with which it should be replaced
optionsOptions modifying search behaviour. Possible values are:
  • None yet
rangeThe range in which to replace the string
Returns
A new string with the occurrences of the specified string replaced

◆ stringByStandardizingPath()

- (OFString *) stringByStandardizingPath

Returns the path with relative sub paths resolved.

Returns
The path with relative sub paths resolved

◆ stringByStandardizingURLPath()

- (OFString *) stringByStandardizingURLPath

Returns the URL path with relative sub paths resolved.

This works similar to stringByStandardizingPath, but is intended for standardization of paths that are part of a URL.

Returns
The URL path with relative sub paths resolved

◆ stringByURLDecoding()

- (OFString *) stringByURLDecoding

Decodes a string used in a URL.

Returns
A new autoreleased string

◆ stringByURLEncoding()

- (OFString *) stringByURLEncoding

Encodes a string for use in a URL.

Returns
A new autoreleased string

◆ stringByURLEncodingWithAllowedCharacters:()

- (OFString *) stringByURLEncodingWithAllowedCharacters: (const char *)  allowed

Encodes a string for use in a URL, but does not escape the specified ignored characters.

Parameters
allowedA C string of characters that should not be escaped
Returns
A new autoreleased string

◆ stringByXMLEscaping()

- (OFString *) stringByXMLEscaping

Escapes a string for use in an XML document.

Returns
A new autoreleased string

◆ stringByXMLUnescapingWithBlock:()

- (OFString *) stringByXMLUnescapingWithBlock: (of_string_xml_unescaping_block_t block

Unescapes XML in the string and uses the specified block for unknown entities.

Parameters
blockA block which handles unknown entities

◆ stringByXMLUnescapingWithDelegate:()

- (OFString *) stringByXMLUnescapingWithDelegate: (nullable id< OFStringXMLUnescapingDelegate >)  delegate

Unescapes XML in the string and uses the specified delegate for unknown entities.

Parameters
delegateAn OFXMLUnescapingDelegate as a handler for unknown entities

◆ stringWithCharacters:length:()

+ (instancetype) stringWithCharacters: (const of_unichar_t *)  characters
length: (size_t)  length 

Creates a new OFString from a Unicode string with the specified length.

Parameters
charactersAn array of Unicode characters
lengthThe length of the Unicode character array
Returns
A new autoreleased OFString

◆ stringWithContentsOfFile:()

+ (instancetype) stringWithContentsOfFile: (OFString *)  path

Creates a new OFString with the contents of the specified UTF-8 encoded file.

Parameters
pathThe path to the file
Returns
A new autoreleased OFString

◆ stringWithContentsOfFile:encoding:()

+ (instancetype) stringWithContentsOfFile: (OFString *)  path
encoding: (of_string_encoding_t encoding 

Creates a new OFString with the contents of the specified file in the specified encoding.

Parameters
pathThe path to the file
encodingThe encoding of the file
Returns
A new autoreleased OFString

◆ stringWithContentsOfURL:()

+ (instancetype) stringWithContentsOfURL: (OFURL *)  URL

Creates a new OFString with the contents of the specified URL.

If the URL's scheme is file, it tries UTF-8 encoding.

If the URL's scheme is http(s), it tries to detect the encoding from the HTTP headers. If it could not detect the encoding using the HTTP headers, it tries UTF-8.

Parameters
URLThe URL to the contents for the string
Returns
A new autoreleased OFString

◆ stringWithContentsOfURL:encoding:()

+ (instancetype) stringWithContentsOfURL: (OFURL *)  URL
encoding: (of_string_encoding_t encoding 

Creates a new OFString with the contents of the specified URL in the specified encoding.

Parameters
URLThe URL to the contents for the string
encodingThe encoding to assume
Returns
A new autoreleased OFString

◆ stringWithCString:encoding:()

+ (instancetype) stringWithCString: (const char *)  cString
encoding: (of_string_encoding_t encoding 

Creates a new OFString from a C string with the specified encoding.

Parameters
cStringA C string to initialize the OFString with
encodingThe encoding of the C string
Returns
A new autoreleased OFString

◆ stringWithCString:encoding:length:()

+ (instancetype) stringWithCString: (const char *)  cString
encoding: (of_string_encoding_t encoding
length: (size_t)  cStringLength 

Creates a new OFString from a C string with the specified encoding and length.

Parameters
cStringA C string to initialize the OFString with
encodingThe encoding of the C string
cStringLengthThe length of the C string
Returns
A new autoreleased OFString

◆ stringWithData:encoding:()

+ (instancetype) stringWithData: (OFData *)  data
encoding: (of_string_encoding_t encoding 

Creates a new OFString from OFData with the specified encoding.

Parameters
dataOFData with the contents of the string
encodingThe encoding in which the string is stored in the OFData
Returns
An new autoreleased OFString

◆ stringWithFormat:()

+ (instancetype) stringWithFormat: (OFConstantString *)  format
,   ... 

Creates a new OFString from a format string.

See printf for the format syntax. As an addition, %@ is available as format specifier for objects, C for of_unichar_t and S for const of_unichar_t *.

Parameters
formatA string used as format to initialize the OFString
Returns
A new autoreleased OFString

◆ stringWithString:()

+ (instancetype) stringWithString: (OFString *)  string

Creates a new OFString from another string.

Parameters
stringA string to initialize the OFString with
Returns
A new autoreleased OFString

◆ stringWithUTF16String:()

+ (instancetype) stringWithUTF16String: (const char16_t *)  string

Creates a new OFString from a UTF-16 encoded string.

Parameters
stringThe UTF-16 string
Returns
A new autoreleased OFString

◆ stringWithUTF16String:byteOrder:()

+ (instancetype) stringWithUTF16String: (const char16_t *)  string
byteOrder: (of_byte_order_t byteOrder 

Creates a new OFString from a UTF-16 encoded string, assuming the specified byte order if no byte order mark is found.

Parameters
stringThe UTF-16 string
byteOrderThe byte order to assume if there is no byte order mark
Returns
A new autoreleased OFString

◆ stringWithUTF16String:length:()

+ (instancetype) stringWithUTF16String: (const char16_t *)  string
length: (size_t)  length 

Creates a new OFString from a UTF-16 encoded string with the specified length.

Parameters
stringThe UTF-16 string
lengthThe length of the UTF-16 string
Returns
A new autoreleased OFString

◆ stringWithUTF16String:length:byteOrder:()

+ (instancetype) stringWithUTF16String: (const char16_t *)  string
length: (size_t)  length
byteOrder: (of_byte_order_t byteOrder 

Creates a new OFString from a UTF-16 encoded string with the specified length, assuming the specified byte order if no byte order mark is found.

Parameters
stringThe UTF-16 string
lengthThe length of the UTF-16 string
byteOrderThe byte order to assume if there is no byte order mark
Returns
A new autoreleased OFString

◆ stringWithUTF32String:()

+ (instancetype) stringWithUTF32String: (const char32_t *)  string

Creates a new OFString from a UTF-32 encoded string.

Parameters
stringThe UTF-32 string
Returns
A new autoreleased OFString

◆ stringWithUTF32String:byteOrder:()

+ (instancetype) stringWithUTF32String: (const char32_t *)  string
byteOrder: (of_byte_order_t byteOrder 

Creates a new OFString from a UTF-32 encoded string, assuming the specified byte order if no byte order mark is found.

Parameters
stringThe UTF-32 string
byteOrderThe byte order to assume if there is no byte order mark
Returns
A new autoreleased OFString

◆ stringWithUTF32String:length:()

+ (instancetype) stringWithUTF32String: (const char32_t *)  string
length: (size_t)  length 

Creates a new OFString from a UTF-32 encoded string with the specified length.

Parameters
stringThe UTF-32 string
lengthThe length of the UTF-32 string
Returns
A new autoreleased OFString

◆ stringWithUTF32String:length:byteOrder:()

+ (instancetype) stringWithUTF32String: (const char32_t *)  string
length: (size_t)  length
byteOrder: (of_byte_order_t byteOrder 

Creates a new OFString from a UTF-32 encoded string with the specified length, assuming the specified byte order if no byte order mark is found.

Parameters
stringThe UTF-32 string
lengthThe length of the UTF-32 string
byteOrderThe byte order to assume if there is no byte order mark
Returns
A new autoreleased OFString

◆ stringWithUTF8String:()

+ (instancetype) stringWithUTF8String: (const char *)  UTF8String

Creates a new OFString from a UTF-8 encoded C string.

Parameters
UTF8StringA UTF-8 encoded C string to initialize the OFString with
Returns
A new autoreleased OFString

◆ stringWithUTF8String:length:()

+ (instancetype) stringWithUTF8String: (const char *)  UTF8String
length: (size_t)  UTF8StringLength 

Creates a new OFString from a UTF-8 encoded C string with the specified length.

Parameters
UTF8StringA UTF-8 encoded C string to initialize the OFString with
UTF8StringLengthThe length of the UTF-8 encoded C string
Returns
A new autoreleased OFString

◆ stringWithUTF8StringNoCopy:freeWhenDone:()

+ (instancetype) stringWithUTF8StringNoCopy: (char *)  UTF8String
freeWhenDone: (bool)  freeWhenDone 

Creates a new OFString from a UTF-8 encoded C string without copying the string.

Parameters
UTF8StringA UTF-8 encoded C string to initialize the OFString with
freeWhenDoneWhether to free the C string when the OFString gets deallocated
Returns
A new autoreleased OFString

◆ substringWithRange:()

- (OFString *) substringWithRange: (of_range_t range

Creates a substring with the specified range.

Parameters
rangeThe range of the substring
Returns
The substring as a new autoreleased OFString

◆ uppercaseString()

- (OFString *) uppercaseString

Returns the string in uppercase.

Returns
The string in uppercase

◆ UTF16String()

- (const char16_t *) UTF16String

Returns the string in UTF-16 encoding with native byte order.

The result is valid until the autorelease pool is released. If you want to use the result outside the scope of the current autorelease pool, you have to copy it.

Returns
The string in UTF-16 encoding with native byte order

◆ UTF16StringLength()

- (size_t) UTF16StringLength

Returns the length of the string in UTF-16 characters.

Returns
The length of string in UTF-16 characters

◆ UTF16StringWithByteOrder:()

- (const char16_t *) UTF16StringWithByteOrder: (of_byte_order_t byteOrder

Returns the string in UTF-16 encoding with the specified byte order.

The result is valid until the autorelease pool is released. If you want to use the result outside the scope of the current autorelease pool, you have to copy it.

Parameters
byteOrderThe byte order for the UTF-16 encoding
Returns
The string in UTF-16 encoding with the specified byte order

◆ UTF32String()

- (const char32_t *) UTF32String

Returns the string in UTF-32 encoding with native byte order.

The result is valid until the autorelease pool is released. If you want to use the result outside the scope of the current autorelease pool, you have to copy it.

Returns
The string in UTF-32 encoding with native byte order

◆ UTF32StringWithByteOrder:()

- (const char32_t *) UTF32StringWithByteOrder: (of_byte_order_t byteOrder

Returns the string in UTF-32 encoding with the specified byte order.

The result is valid until the autorelease pool is released. If you want to use the result outside the scope of the current autorelease pool, you have to copy it.

Parameters
byteOrderThe byte order for the UTF-32 encoding
Returns
The string in UTF-32 encoding with the specified byte order

◆ UTF8String()

- (const char *) UTF8String

Returns the OFString as a UTF-8 encoded C string.

The result is valid until the autorelease pool is released. If you want to use the result outside the scope of the current autorelease pool, you have to copy it.

Returns
The OFString as a UTF-8 encoded C string

◆ UTF8StringLength()

- (size_t) UTF8StringLength

Returns the number of bytes the string needs in UTF-8 encoding.

Returns
The number of bytes the string needs in UTF-8 encoding.

◆ writeToFile:()

- (void) writeToFile: (OFString *)  path

Writes the string into the specified file using UTF-8 encoding.

Parameters
pathThe path of the file to write to

◆ writeToFile:encoding:()

- (void) writeToFile: (OFString *)  path
encoding: (of_string_encoding_t encoding 

Writes the string into the specified file using the specified encoding.

Parameters
pathThe path of the file to write to
encodingThe encoding to use to write the string into the file

The documentation for this class was generated from the following files: