# util >**NOTE:** >The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version. This module provides common utility functions, such as **TextEncoder** and **TextDecoder** for string encoding and decoding, **RationalNumber** for rational number operations, **LruBuffer** for buffer management, **Scope** for range determination, **Base64** for Base64 encoding and decoding, and **Types** for checks of built-in object types. ## Modules to Import ``` import util from '@ohos.util'; ``` ## Required Permissions None. ## util.printf printf\(format: string, ...args: Object\[\]\): string Prints the input content in a formatted string. - Parameters
Callback, in which the first parameter indicates the cause of the rejection (the value is null if the promise has been resolved) and the second parameter indicates the resolved value. |
Function in the error-first style (that is, (err, value) =>... is called as the last parameter) and the promise version. |
Encoding-related options, which include fatal and ignoreBOM. |
Returns 0 if the two objects are equal; returns 1 if the given object is less than this object; return -1 if the given object is greater than this object. |
Returns true if the two objects are equal; returns false otherwise. |
Returns true if the value of this RationalNumber object is 0; returns false otherwise. |
Returns true if this RationalNumber object is a NaN (the denominator and numerator are both 0); returns false otherwise. |
Returns true if this RationalNumber object represents a finite value (the denominator is not 0); returns false otherwise. |
Returns NaN if the numerator and denominator of this object are both 0; returns a string in Numerator/Denominator format otherwise, for example, 3/5. |
Returns the value of the key if a match is found in the buffer; returns undefined otherwise. |
Returns the existing value if the key already exists; returns the value added otherwise. If the key or value is null, an exception will be thrown. |
All values in the buffer, listed from the most to the least recently accessed. |
All keys in the buffer, listed from the most to the least recently accessed. |
Returns an Optional object containing the deleted key-value pair if the key exists in the buffer; returns an empty Optional object otherwise. If the key is null, an exception will be thrown. |
Returns true if the buffer contains the specified key; returns false otherwise. |
Intersection of this Scope and the given lower and upper limits. |
Union set of this Scope and the given lower and upper limits. |
Returns true if the value is within this Scope; returns false otherwise. |
Returns true if the range is within this Scope; returns false otherwise. |
Returns lowerObj if the specified value is less than the lower limit; returns upperObj if the specified value is greater than the upper limit; returns the specified value if it is within this Scope. |
Returns true if the input value is of the ArrayBuffer type; returns false otherwise. |
Returns true if the input value is of the ArrayBufferView type; returns false otherwise. |
Returns true if the input value is of the arguments type; returns false otherwise. |
Returns true if the input value is of the ArrayBuffer type; returns false otherwise. |
Returns true if the input value is an asynchronous function; returns false otherwise. |
Returns true if the input value is of the Boolean type; returns false otherwise. |
Returns true if the input value is of the Boolean, Number, String, or Symbol type; returns false otherwise. |
Returns true if the input value is of the DataView type; returns false otherwise. |
Returns true if the input value is of the Data type; returns false otherwise. |
Returns true if the input value is of the native external type; returns false otherwise. |
Returns true if the input value is of the Float32Array type; returns false otherwise. |
Returns true if the input value is of the Float64Array type; returns false otherwise. |
Returns true if the input value is a generator function; returns false otherwise. |
Returns true if the input value is a generator object; returns false otherwise. |
Returns true if the input value is of the Int8Array type; returns false otherwise. |
Returns true if the input value is of the Int16Array type; returns false otherwise. |
Returns true if the input value is of the Int32Array type; returns false otherwise. |
Returns true if the input value is of the Map type; returns false otherwise. |
Returns true if the input value is of the MapIterator type; returns false otherwise. |
Returns true if the input value is of the Error type; returns false otherwise. |
Returns true if the input value is a number object; returns false otherwise. |
Returns true if the input value is a promise; returns false otherwise. |
Returns true if the input value is a proxy; returns false otherwise. |
Returns true if the input value is of the RegExp type; returns false otherwise. |
Returns true if the input value is of the Set type; returns false otherwise. |
Returns true if the input value is of the SetIterator type; returns false otherwise. |
Returns true if the input value is a string object; returns false otherwise. |
Returns true if the input value is a symbol object; returns false otherwise. |
Returns true if the input value is of the TypedArray type; returns false otherwise. |
Returns true if the input value is of the Uint8Array type; returns false otherwise. |
Returns true if the input value is of the Uint8ClampedArray type; returns false otherwise. |
Returns true if the input value is of the Uint16Array type; returns false otherwise. |
Returns true if the input value is of the Uint32Array type; returns false otherwise. |
Returns true if the input value is of the WeakMap type; returns false otherwise. |
Returns true if the input value is of the WeakSet type; returns false otherwise. |