ANSI轉為HTML5函式庫
<?php namespace SensioLabs\AnsiConverter\Tests; use SensioLabs\AnsiConverter\AnsiToHtmlConverter; class AnsiToHtmlConverterTest extends \PHPUnit_Framework_TestCase { /** * @dataProvider getConvertData */ public function testConvert($expected, $input) { $converter = new AnsiToHtmlConverter(); $this->assertEquals($expected, $converter->convert($input)); } public function getConvertData() { return array( // text is escaped array('<span style="background-color: black; color: white">foo <br /></span>', 'foo <br />'), // newlines are preserved array("<span style=\"background-color: black; color: white\">foo\nbar</span>", "foo\nbar"), // backspaces array('<span style="background-color: black; color: white">foo </span>', "foobar\x08\x08\x08 "), array('<span style="background-color: black; color: white">foo</span><span style="background-color: black; color: white"> </span>', "foob\e[31;41ma\e[0mr\x08\x08\x08 "), // color array('<span style="background-color: darkred; color: darkred">foo</span>', "\e[31;41mfoo\e[0m"), // color with [m as a termination (equivalent to [0m]) array('<span style="background-color: darkred; color: darkred">foo</span>', "\e[31;41mfoo\e[m"), // bright color array('<span style="background-color: red; color: red">foo</span>', "\e[31;41;1mfoo\e[0m"), // carriage returns array('<span style="background-color: black; color: white">foobar</span>', "foo\rbar\rfoobar"), // underline array('<span style="background-color: black; color: white; text-decoration: underline">foo</span>', "\e[4mfoo\e[0m"), // non valid unicode codepoints substitution (only available with PHP >= 5.4) PHP_VERSION_ID < 50400 ?: array('<span style="background-color: black; color: white">foo '."\xEF\xBF\xBD".'</span>', "foo \xF4\xFF\xFF\xFF"), ); } }
ANSI是一種字元代碼,為使電腦支援更多語言,通常使用 0x00~0x7f 範圍的1 個位元組來表示 1 個英文字元。超出此範圍的使用0x80~0xFFFF來編碼,即擴展的ASCII編碼。
HTML則是超文本標記語言,標準通用標記語言下的一個應用。 「超文本」是指頁面內可以包含圖片、鏈接,甚至音樂、程式等非文字元素。超文本標記語言的結構包括「頭」部分(英文:Head)、和「主體」部分(英
免責聲明
本站所有資源皆由網友貢獻或各大下載網站轉載。請自行檢查軟體的完整性!本站所有資源僅供學習參考。請不要將它們用於商業目的。否則,一切後果都由您負責!如有侵權,請聯絡我們刪除。聯絡方式:admin@php.cn
相關文章

07 Dec 2024
Python 中 MySQL 連接的轉義字串當使用資料庫時,管理複雜的字串可能具有挑戰性,特別是當它...

24 Oct 2024
本文討論了 C 標準函式庫中缺少 pow(int, int) 函數的原因。它探討了歷史原因,包括 C 語言的遺產、其他功能的機會成本以及限制

24 Dec 2024
了解 Python 類別繼承在 Python 中,類別可以從其他類別繼承,這使它們能夠存取父類別的屬性並...

02 Dec 2024
使用庫將 JSON 資料轉換為 HTML 表格從 JSON 資料建立動態 HTML 表格是 Web 開發中的常見任務。雖然它是...

21 Jul 2016
PHP5試用(二)。抽象類別 抽象類別不能被實例化。 抽象類別與其它類別一樣,允許定義變數及方法。 抽象類別同樣可以定義一個抽象的方法,抽象類別的方法不會被執


Hot Tools

熱門文章
丟失記錄:Bloom&Rage -Corey和Dylan的鎖組合
19 Feb 2025
手游攻略
Longvinter:完整的釣魚指南
21 Feb 2025
手游攻略
王國來:拯救2-婚禮要買的衣服
05 Feb 2025
手游攻略
王國來:拯救2-如何獲得Comfrey
07 Feb 2025
手游攻略
Hello Kitty Island冒險:重新啟動機器人任務演練
16 Feb 2025
手游攻略