Lista de Classes
- App\Middleware\Cors
- App\Middleware\Auth
- App\Middleware\Env
- AppMin
- Application
- Route
- Data\Database
- Data\Db2Database
- Data\OdbcDatabase
- Data\Validator
- Data\KeyValue\SqliteStorage
- Data\Log\FileLogger
- Data\Log\HtmlLogger
- Encoding\Base64Url
- Encoding\Json
- Encoding\Utf8
- Environment\DotEnv
- Environment\System
- FileSystem\Search
- FileSystem\Security
- FileSystem\Sync
- Lang\I18N
- Lang\L10N
- Lang\Time
- Media\Image
- Net\Config
- Net\Email
- Net\HttpClient
- Net\HttpResponse
- Net\IP
- Net\SmtpClient
- Security\Crypto
- Security\Password
- Security\Crypto\Encryption
- Security\Crypto\FileEncryption
- Security\Crypto\JWT
- Security\Crypto\PublicKey
- Security\Crypto\Random
- Security\Crypto\SignedData
- Security\Web\CsrfSession
- Security\Web\CsrfStateless
- Security\Web\RateLimit
- Web\Request
- Web\Response
FastSitePHP\Encoding\Utf8
UTF-8 Encoding
For most PHP sites UTF-8 is the default character set and using this class is not needed. This class is useful for forcing different character sets to UTF-8 prior to JSON or XML encoding.
The PHP function [json_encode()] requires UTF-8 prior to encoding, otherwise it will trigger an error:
JSON_ERROR_UTF8 - 'Malformed UTF-8 characters, possibly incorrectly encoded'
For example, IBM i-Series Servers use EBCDIC character encoding which correctly translates to UTF-8 for most characters, however it will trigger the error for some characters.
Another example is on FastSitePHP's Encryption Unit Tests, an array of binary strings need to be converted to UTF-8 prior to JSON encoding and hashing. Using this for binary data in most situations is not recommended, rather if you are working with binary files or data use binary format directly.
Código Fonte
Links Relacionados
Métodos
encode($data)
Encode data to UTF-8
Retorna: string