mirror of
https://github.com/fofolee/uTools-Manuals.git
synced 2025-10-26 06:11:23 +08:00
52 lines
4.3 KiB
HTML
52 lines
4.3 KiB
HTML
<div class="container">
|
||
<h1 id="pkg-overview">package hex</h1>
|
||
<p><code>import "encoding/hex"</code>
|
||
</p><p>hex包实现了16进制字符表示的编解码。</p>
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
<h2 id="pkg-variables">Variables </h2>
|
||
<pre>var <span id="ErrLength">ErrLength</span> = <a href="errors.htm">errors</a>.<a href="errors.htm#New">New</a>("encoding/hex: odd length hex string")</pre>
|
||
<p>解码一个长度为奇数的切片时,将返回此错误。</p>
|
||
<h2 id="InvalidByteError">type <a href="https://github.com/golang/go/blob/master/src/encoding/hex/hex.go?name=release#37" title="View Source">InvalidByteError</a> </h2>
|
||
<pre>type InvalidByteError <a href="builtin.htm#byte">byte</a></pre>
|
||
<p>描述一个hex编码字符串中的非法字符。</p>
|
||
<h3 id="InvalidByteError.Error">func (InvalidByteError) <a href="https://github.com/golang/go/blob/master/src/encoding/hex/hex.go?name=release#39" title="View Source">Error</a> </h3>
|
||
<pre class="funcdecl">func (e <a href="#InvalidByteError">InvalidByteError</a>) Error() <a href="builtin.htm#string">string</a></pre>
|
||
<h2 id="DecodedLen">func <a href="https://github.com/golang/go/blob/master/src/encoding/hex/hex.go?name=release#43" title="View Source">DecodedLen</a> </h2>
|
||
<pre class="funcdecl">func DecodedLen(x <a href="builtin.htm#int">int</a>) <a href="builtin.htm#int">int</a></pre>
|
||
<p>长度x的编码数据解码后的明文数据的长度</p>
|
||
<h2 id="Decode">func <a href="https://github.com/golang/go/blob/master/src/encoding/hex/hex.go?name=release#49" title="View Source">Decode</a> </h2>
|
||
<pre class="funcdecl">func Decode(dst, src []<a href="builtin.htm#byte">byte</a>) (<a href="builtin.htm#int">int</a>, <a href="builtin.htm#error">error</a>)</pre>
|
||
<p>将src解码为DecodedLen(len(src))字节,返回实际写入dst的字节数;如遇到非法字符,返回描述错误的error。</p>
|
||
<h2 id="DecodeString">func <a href="https://github.com/golang/go/blob/master/src/encoding/hex/hex.go?name=release#91" title="View Source">DecodeString</a> </h2>
|
||
<pre class="funcdecl">func DecodeString(s <a href="builtin.htm#string">string</a>) ([]<a href="builtin.htm#byte">byte</a>, <a href="builtin.htm#error">error</a>)</pre>
|
||
<p>返回hex编码的字符串s代表的数据。</p>
|
||
<h2 id="EncodedLen">func <a href="https://github.com/golang/go/blob/master/src/encoding/hex/hex.go?name=release#18" title="View Source">EncodedLen</a> </h2>
|
||
<pre class="funcdecl">func EncodedLen(n <a href="builtin.htm#int">int</a>) <a href="builtin.htm#int">int</a></pre>
|
||
<p>长度x的明文数据编码后的编码数据的长度。</p>
|
||
<h2 id="Encode">func <a href="https://github.com/golang/go/blob/master/src/encoding/hex/hex.go?name=release#24" title="View Source">Encode</a> </h2>
|
||
<pre class="funcdecl">func Encode(dst, src []<a href="builtin.htm#byte">byte</a>) <a href="builtin.htm#int">int</a></pre>
|
||
<p>将src的数据解码为EncodedLen(len(src))字节,返回实际写入dst的字节数:EncodedLen(len(src))。</p>
|
||
<h2 id="EncodeToString">func <a href="https://github.com/golang/go/blob/master/src/encoding/hex/hex.go?name=release#84" title="View Source">EncodeToString</a> </h2>
|
||
<pre class="funcdecl">func EncodeToString(src []<a href="builtin.htm#byte">byte</a>) <a href="builtin.htm#string">string</a></pre>
|
||
<p>将数据src编码为字符串s。</p>
|
||
<h2 id="Dump">func <a href="https://github.com/golang/go/blob/master/src/encoding/hex/hex.go?name=release#103" title="View Source">Dump</a> </h2>
|
||
<pre class="funcdecl">func Dump(data []<a href="builtin.htm#byte">byte</a>) <a href="builtin.htm#string">string</a></pre>
|
||
<p>返回给定数据的hex dump格式的字符串,这个字符串与控制台下`hexdump -C`对该数据的输出是一致的。</p>
|
||
<h2 id="Dumper">func <a href="https://github.com/golang/go/blob/master/src/encoding/hex/hex.go?name=release#114" title="View Source">Dumper</a> </h2>
|
||
<pre class="funcdecl">func Dumper(w <a href="io.htm">io</a>.<a href="io.htm#Writer">Writer</a>) <a href="io.htm">io</a>.<a href="io.htm#WriteCloser">WriteCloser</a></pre>
|
||
<p>返回一个io.WriteCloser接口,将写入的数据的hex dump格式写入w,具体格式为'hexdump -C'。</p>
|
||
</div> |