<?php /* * This file is part of ansi-to-html. * * (c) 2013 Fabien Potencier * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace SensioLabs\AnsiConverter; use SensioLabs\AnsiConverter\Theme\Theme; /** * Converts an ANSI text to HTML5. */ class AnsiToHtmlConverter { protected $theme; protected $charset; protected $inlineStyles; protected $inlineColors; protected $colorNames; public function __construct(Theme $theme = null, $inlineStyles = true, $charset = 'UTF-8') { $this->theme = null === $theme ? new Theme() : $theme; $this->inlineStyles = $inlineStyles; $this->charset = $charset; $this->inlineColors = $this->theme->asArray(); $this->colorNames = array( 'black', 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white', '', '', 'brblack', 'brred', 'brgreen', 'bryellow', 'brblue', 'brmagenta', 'brcyan', 'brwhite', );
ANSI is a character code. In order to enable the computer to support more languages, 1 byte in the range of 0x00~0x7f is usually used to represent 1 English character. Anything outside this range is encoded using 0x80~0xFFFF, which is extended ASCII encoding.
In order for the computer to support more languages, 2 bytes in the range of 0x80~0xFFFF are usually used to represent 1 character. For example: the Chinese character '中' is stored in
ANSI encoding
ANSI encoding
Chinese operating system, using the two bytes [0xD6,0xD0] for storage.
Different countries and regions have formulated different standards, resulting in their own encoding standards such as GB2312, GBK, GB18030, Big5, and Shift_JIS. These various Chinese character extended encoding methods that use multiple bytes to represent a character are called ANSI encoding. In the Simplified Chinese Windows operating system, ANSI encoding represents GBK encoding; in the Traditional Chinese Windows operating system, ANSI encoding represents Big5; in the Japanese Windows operating system, ANSI encoding represents Shift_JIS encoding.
Different ANSI codes are incompatible with each other. When information is exchanged internationally, text belonging to two languages cannot be stored in the same ANSI coded text.
ANSI encoding uses one byte to represent English characters, and two or four bytes to represent Chinese characters.
All resources on this site are contributed by netizens or reprinted by major download sites. Please check the integrity of the software yourself! All resources on this site are for learning reference only. Please do not use them for commercial purposes. Otherwise, you will be responsible for all consequences! If there is any infringement, please contact us to delete it. Contact information: admin@php.cn
Related Article
06May2023
There are many libraries in PHP that can be used to convert PowerPoint presentations (PPT) into image formats. These libraries can be used to convert PPT to images in PNG, JPEG or other formats, easily inserting them into web pages, or displaying them in other applications (such as e-book readers). In this article, we will discuss how to convert PPT to image format using PHP. We will use the PowerPoint to picture example in the OfficeConverter library to demonstrate this process. Step 1: Download and install
14Apr2023
Recently, while using golang, I encountered a problem, that is, how to convert ansi code to actual color in the terminal. The ANSI code identifies a series of control characters, one of which sets the color. In the past, terminals were black and white. Later, with the emergence of color terminals, the terminals' support for ANSI codes became better and better. Many terminals now support converting ANSI codes to actual colors. In golang, we can use some libraries to achieve this purpose, such as ANSI library or color library. Below, I will introduce how to use
17Apr2024
The steps for writing a function library in PHP are as follows: Create a PHP file (such as myFunctions.php) to store the functions. Use the function keyword to define functions in a file. Include libraries in other scripts using require_once or include_once statements. Once a function library is included, its functions can be used.
30Sep2016
Looking for a php/python library management program (similar to Baidu library, managing doc/pdf and other libraries)~~ It mainly needs to have search functions, especially file classification retrieval/file tag retrieval functions, no need for online conversion, online browsing!
26Apr2024
PHP function libraries can improve code reusability by encapsulating common tasks. To create a reusable library that supports different PHP versions: define the library and compatible PHP version ranges; handle version differences based on PHP version; package the library for use by other projects.
13Apr2023
PHP is a widely used programming language used for developing websites and applications. Microsoft Excel is a popular spreadsheet application used by many businesses to store and manage large amounts of data. Therefore, PHP conversion to xls is a common need to help businesses import Excel data into their websites and applications. Generally speaking, PHP can access Excel files on the server side while using some libraries and tools to convert xls files to other formats such as CSV or XML. These formats
Hot Tools
PHP library for dependency injection containers
PHP library for dependency injection containers
A collection of 50 excellent classic PHP algorithms
Classic PHP algorithm, learn excellent ideas and expand your thinking
Small PHP library for optimizing images
Small PHP library for optimizing images