📄 encoding.n
字号:
'\"'\" Copyright (c) 1998 by Scriptics Corporation.'\" '\" See the file "license.terms" for information on usage and redistribution'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.'\" '\" RCS: @(#) $Id: encoding.n,v 1.3 2000/09/07 14:27:47 poenitz Exp $'\" .so man.macros.TH encoding n "8.1" Tcl "Tcl Built-In Commands".BS.SH NAMEencoding \- Manipulate encodings.SH SYNOPSIS\fBencoding \fIoption\fR ?\fIarg arg ...\fR?.BE.SH INTRODUCTION.PPStrings in Tcl are encoded using 16-bit Unicode characters. Differentoperating system interfaces or applications may generate strings inother encodings such as Shift-JIS. The \fBencoding\fR command helpsto bridge the gap between Unicode and these other formats..SH DESCRIPTION.PPPerforms one of several encoding related operations, depending on\fIoption\fR. The legal \fIoption\fRs are:.TP\fBencoding convertfrom ?\fIencoding\fR? \fIdata\fRConvert \fIdata\fR to Unicode from the specified \fIencoding\fR. Thecharacters in \fIdata\fR are treated as binary data where the lower8-bits of each character is taken as a single byte. The resultingsequence of bytes is treated as a string in the specified\fIencoding\fR. If \fIencoding\fR is not specified, the currentsystem encoding is used..TP\fBencoding convertto ?\fIencoding\fR? \fIstring\fRConvert \fIstring\fR from Unicode to the specified \fIencoding\fR.The result is a sequence of bytes that represents the convertedstring. Each byte is stored in the lower 8-bits of a Unicodecharacter. If \fIencoding\fR is not specified, the currentsystem encoding is used..TP\fBencoding names\fRReturns a list containing the names of all of the encodings that arecurrently available. .TP\fBencoding system\fR ?\fIencoding\fR?Set the system encoding to \fIencoding\fR. If \fIencoding\fR isomitted then the command returns the current system encoding. Thesystem encoding is used whenever Tcl passes strings to system calls..SH EXAMPLE.PPIt is common practice to write script files using a text editor thatproduces output in the euc-jp encoding, which represents the ASCIIcharacters as singe bytes and Japanese characters as two bytes. Thismakes it easy to embed literal strings that correspond to non-ASCIIcharacters by simply typing the strings in place in the script.However, because the \fBsource\fR command always reads files using theISO8859-1 encoding, Tcl will treat each byte in the file as a separatecharacter that maps to the 00 page in Unicode. Theresulting Tcl strings will not contain the expected Japanesecharacters. Instead, they will contain a sequence of Latin-1characters that correspond to the bytes of the original string. The\fBencoding\fR command can be used to convert this string to theexpected Japanese Unicode characters. For example,.CS set s [encoding convertfrom euc-jp "\\xA4\\xCF"].CEwould return the Unicode string "\\u306F", which is the Hiraganaletter HA..SH "SEE ALSO"Tcl_GetEncoding(3).SH KEYWORDSencoding
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -