mirror of
https://github.com/fofolee/uTools-Manuals.git
synced 2025-06-18 22:06:57 +08:00
70 lines
2.6 KiB
HTML
70 lines
2.6 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||
<html>
|
||
<head>
|
||
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||
<title>将 ISO-8859-1 编码的字符串转换为 UTF-8 编码</title>
|
||
</head>
|
||
<body class="docs"><div id="layout">
|
||
<div id="layout-content"><div id="function.utf8-encode" class="refentry">
|
||
<div class="refnamediv">
|
||
<h1 class="refname">utf8_encode</h1>
|
||
<p class="verinfo">(PHP 4, PHP 5, PHP 7)</p><p class="refpurpose"><span class="refname">utf8_encode</span> — <span class="dc-title">将 ISO-8859-1 编码的字符串转换为 UTF-8 编码</span></p>
|
||
|
||
</div>
|
||
<div class="refsect1 unknown-unknown-returnvalueu" id="refsect1-function.utf8-encode-unknown-unknown-returnvalueu">
|
||
<h3 class="title">描述</h3>
|
||
<div class="methodsynopsis dc-description">
|
||
<span class="methodname"><strong>utf8_encode</strong></span>
|
||
( <span class="methodparam"><span class="type">string</span> <code class="parameter">$data</code></span>
|
||
) : <span class="type">string</span></div>
|
||
|
||
<p class="para rdfs-comment">
|
||
该函数将 <code class="parameter">data</code> 字符串转换为 <em>UTF-8</em> 编码,并返回编码后的字符串。<em>UTF-8</em> 是一种用于将<span class="glossterm">宽字符</span>值转换为字节流的 <acronym title="Unique, Universal, and Uniform character enCoding">Unicode</acronym> 的标准机制。<em>UTF-8</em> 对于纯 <abbr class="abbrev">ASCII</abbr> 字符来说是透明的,且是自同步的(也就是说这使得程序能够得知字符从字节流的何处开始),并可被普通字符串比较函数用以比较等操作。PHP 可将 <em>UTF-8</em> 编码为多达四个字节的字符,如:
|
||
<table class="doctable table">
|
||
<caption><strong>UTF-8 编码</strong></caption>
|
||
|
||
<thead>
|
||
<tr>
|
||
<th>字节(bytes)</th>
|
||
<th>位(bits)</th>
|
||
<th>表 示</th>
|
||
</tr>
|
||
|
||
</thead>
|
||
|
||
<tbody class="tbody">
|
||
<tr>
|
||
<td>1</td>
|
||
<td>7</td>
|
||
<td>0bbbbbbb</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td>2</td>
|
||
<td>11</td>
|
||
<td>110bbbbb 10bbbbbb</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td>3</td>
|
||
<td>16</td>
|
||
<td>1110bbbb 10bbbbbb 10bbbbbb</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td>4</td>
|
||
<td>21</td>
|
||
<td>11110bbb 10bbbbbb 10bbbbbb 10bbbbbb</td>
|
||
</tr>
|
||
|
||
</tbody>
|
||
|
||
</table>
|
||
|
||
</p>
|
||
<p class="para">
|
||
每个 <em>UTF-8</em> 表示一个能被用以储存字符数据的位。
|
||
</p>
|
||
</div>
|
||
|
||
</div></div></div></body></html> |