<?php //Author: parfait.team@gmail.com function utf8ToUnicode($str){ //split word $c = ""; foreach($matches[0] as $m){ } return $c; } function unicodeToUtf8($unicode_str){ $retr = ""; foreach($intArr as $cval) { $retr .= unicodeCharToUtf8($cval); } return $retr; } function unicodeCharToUtf8($unicode_c){ $f=0x80; // 10000000 $str = ""; // U-00000000 - U-0000007F: 0xxxxxxx if($unicode_c_val <= 0x7F) { } //U-00000080 - U-000007FF: 110xxxxx 10xxxxxx else if($unicode_c_val >= 0x80 && $unicode_c_val <= 0x7FF) { $h=0xC0; // 11000000 $c1 = $unicode_c_val >> 6 | $h; $c2 = ($unicode_c_val & 0x3F) | $f; } //U-00000800 - U-0000FFFF: 1110xxxx 10xxxxxx 10xxxxxx else if($unicode_c_val >= 0x800 && $unicode_c_val <= 0xFFFF) { $h=0xE0; // 11100000 $c1 = $unicode_c_val >> 12 | $h; $c2 = (($unicode_c_val & 0xFC0) >> 6) | $f; $c3 = ($unicode_c_val & 0x3F) | $f; } //U-00010000 - U-001FFFFF: 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx else if($unicode_c_val >= 0x10000 && $unicode_c_val <= 0x1FFFFF) { $h=0xF0; // 11110000 $c1 = $unicode_c_val >> 18 | $h; $c2 = (($unicode_c_val & 0x3F000) >>12) | $f; $c3 = (($unicode_c_val & 0xFC0) >>6) | $f; $c4 = ($unicode_c_val & 0x3F) | $f; } //U-00200000 - U-03FFFFFF: 111110xx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx else if($unicode_c_val >= 0x200000 && $unicode_c_val <= 0x3FFFFFF) { $h=0xF8; // 11111000 $c1 = $unicode_c_val >> 24 | $h; $c2 = (($unicode_c_val & 0xFC0000)>>18) | $f; $c3 = (($unicode_c_val & 0x3F000) >>12) | $f; $c4 = (($unicode_c_val & 0xFC0) >>6) | $f; $c5 = ($unicode_c_val & 0x3F) | $f; } //U-04000000 - U-7FFFFFFF: 1111110x 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx else if($unicode_c_val >= 0x4000000 && $unicode_c_val <= 0x7FFFFFFF) { $h=0xFC; // 11111100 $c1 = $unicode_c_val >> 30 | $h; $c2 = (($unicode_c_val & 0x3F000000)>>24) | $f; $c3 = (($unicode_c_val & 0xFC0000)>>18) | $f; $c4 = (($unicode_c_val & 0x3F000) >>12) | $f; $c5 = (($unicode_c_val & 0xFC0) >>6) | $f; $c6 = ($unicode_c_val & 0x3F) | $f; } return $str; } //Print result $raw_str = " 雨傘運動或稱雨傘革命、遮打運動、遮打革命(英語:Umbrella Movement 或 Umbrella Revolution)是於2014年9月26日起在香港為爭取真普選而發起的一系列公民抗命,逾60-70萬(人次)香港市民佔據多個主要商業區靜坐及示威,地點包括金鐘、中環、灣仔、銅鑼灣、旺角和尖沙咀,旨在要求包括撤回中國全國人大常委會(人大常委)所確定之2017年行政長官選舉及2016年立法會選舉框架和候選人提名方案,爭取行政長官選舉的公民提名權及取消立法會功能界別等訴求。 The 2014 Hong Kong protests, also known as the Umbrella Movement or Umbrella Revolution, began in September 2014 when activists in Hong Kong protested outside the HKSAR government headquarters and occupied several major city intersections after China's Standing Committee of the National People's Congress (NPCSC) announced its decision on proposed electoral reform.[7] In disallowing civil nominations, the NPCSC made it clear that a 1200-member nominating committee, which would remain nominated by the business factions, would elect two to three electoral candidates with more than half of the votes before the general public could vote on them "; $unicode_str = utf8ToUnicode($raw_str); $utf8_str = unicodeToUtf8($unicode_str); ?> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> </head> <body> <b>Raw text:</b><br/> <?=$raw_str?><br/><br/> <b>UTF8 to Unicode:</b><br/> <?=$unicode_str?><br/><br/> <b>Unicode to UTF8:</b><br/> <?=$utf8_str?> </body> </html>
Standard input is empty
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> </head> <body> <b>Raw text:</b><br/> 雨傘運動或稱雨傘革命、遮打運動、遮打革命(英語:Umbrella Movement 或 Umbrella Revolution)是於2014年9月26日起在香港為爭取真普選而發起的一系列公民抗命,逾60-70萬(人次)香港市民佔據多個主要商業區靜坐及示威,地點包括金鐘、中環、灣仔、銅鑼灣、旺角和尖沙咀,旨在要求包括撤回中國全國人大常委會(人大常委)所確定之2017年行政長官選舉及2016年立法會選舉框架和候選人提名方案,爭取行政長官選舉的公民提名權及取消立法會功能界別等訴求。 The 2014 Hong Kong protests, also known as the Umbrella Movement or Umbrella Revolution, began in September 2014 when activists in Hong Kong protested outside the HKSAR government headquarters and occupied several major city intersections after China's Standing Committee of the National People's Congress (NPCSC) announced its decision on proposed electoral reform.[7] In disallowing civil nominations, the NPCSC made it clear that a 1200-member nominating committee, which would remain nominated by the business factions, would elect two to three electoral candidates with more than half of the votes before the general public could vote on them <br/><br/> <b>UTF8 to Unicode:</b><br/> 雨傘運動或稱雨傘革命、遮打運動、遮打革命(英語:Umbrella Movement 或 Umbrella Revolution)是於2014年9月26日起在香港為爭取真普選而發起的一系列公民抗命,逾60-70萬(人次)香港市民佔據多個主要商業區靜坐及示威,地點包括金鐘、中環、灣仔、銅鑼灣、旺角和尖沙咀,旨在要求包括撤回中國全國人大常委會(人大常委)所確定之2017年行政長官選舉及2016年立法會選舉框架和候選人提名方案,爭取行政長官選舉的公民提名權及取消立法會功能界別等訴求。The 2014 Hong Kong protests, also known as the Umbrella Movement or Umbrella Revolution, began in September 2014 when activists in Hong Kong protested outside the HKSAR government headquarters and occupied several major city intersections after China's Standing Committee of the National People's Congress (NPCSC) announced its decision on proposed electoral reform.[7] In disallowing civil nominations, the NPCSC made it clear that a 1200-member nominating committee, which would remain nominated by the business factions, would elect two to three electoral candidates with more than half of the votes before the general public could vote on them<br/><br/> <b>Unicode to UTF8:</b><br/> 雨傘運動或稱雨傘革命、遮打運動、遮打革命(英語:Umbrella Movement 或 Umbrella Revolution)是於2014年9月26日起在香港為爭取真普選而發起的一系列公民抗命,逾60-70萬(人次)香港市民佔據多個主要商業區靜坐及示威,地點包括金鐘、中環、灣仔、銅鑼灣、旺角和尖沙咀,旨在要求包括撤回中國全國人大常委會(人大常委)所確定之2017年行政長官選舉及2016年立法會選舉框架和候選人提名方案,爭取行政長官選舉的公民提名權及取消立法會功能界別等訴求。The 2014 Hong Kong protests, also known as the Umbrella Movement or Umbrella Revolution, began in September 2014 when activists in Hong Kong protested outside the HKSAR government headquarters and occupied several major city intersections after China's Standing Committee of the National People's Congress (NPCSC) announced its decision on proposed electoral reform.[7] In disallowing civil nominations, the NPCSC made it clear that a 1200-member nominating committee, which would remain nominated by the business factions, would elect two to three electoral candidates with more than half of the votes before the general public could vote on them </body> </html>