⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 utf.3

📁 tcl是工具命令语言
💻 3
字号:
'\"'\" Copyright (c) 1997 Sun Microsystems, Inc.'\"'\" See the file "license.terms" for information on usage and redistribution'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.'\" '\" RCS: @(#) $Id: Utf.3,v 1.13 2002/07/01 18:24:39 jenglish Exp $'\" .so man.macros.TH Utf 3 "8.1" Tcl "Tcl Library Procedures".BS.SH NAMETcl_UniChar, Tcl_UniCharCaseMatch, Tcl_UniCharNcasecmp, Tcl_UniCharToUtf, Tcl_UtfToUniChar, Tcl_UniCharToUtfDString, Tcl_UtfToUniCharDString, Tcl_UniCharLen, Tcl_UniCharNcmp, Tcl_UtfCharComplete, Tcl_NumUtfChars, Tcl_UtfFindFirst, Tcl_UtfFindLast, Tcl_UtfNext, Tcl_UtfPrev, Tcl_UniCharAtIndex, Tcl_UtfAtIndex, Tcl_UtfBackslash \- routines for manipulating UTF-8 strings..SH SYNOPSIS.nf\fB#include <tcl.h>\fR.sptypedef ... Tcl_UniChar;.spint\fBTcl_UniCharToUtf\fR(\fIch, buf\fR).spint\fBTcl_UtfToUniChar\fR(\fIsrc, chPtr\fR).VS 8.4.spchar *\fBTcl_UniCharToUtfDString\fR(\fIuniStr, numChars, dstPtr\fR).spTcl_UniChar *\fBTcl_UtfToUniCharDString\fR(\fIsrc, len, dstPtr\fR).VE 8.4.spint\fBTcl_UniCharLen\fR(\fIuniStr\fR).spint\fBTcl_UniCharNcmp\fR(\fIuniStr, uniStr, num\fR).VS 8.4.spint\fBTcl_UniCharNcasecmp\fR(\fIuniStr, uniStr, num\fR).spint\fBTcl_UniCharCaseMatch\fR(\fIuniStr, uniPattern, nocase\fR).VE 8.4.spint\fBTcl_UtfNcmp\fR(\fIsrc, src, num\fR).spint\fBTcl_UtfNcasecmp\fR(\fIsrc, src, num\fR).spint\fBTcl_UtfCharComplete\fR(\fIsrc, len\fR).spint \fBTcl_NumUtfChars\fR(\fIsrc, len\fR).VS 8.4.spCONST char *\fBTcl_UtfFindFirst\fR(\fIsrc, ch\fR).spCONST char *\fBTcl_UtfFindLast\fR(\fIsrc, ch\fR).spCONST char *\fBTcl_UtfNext\fR(\fIsrc\fR).spCONST char *\fBTcl_UtfPrev\fR(\fIsrc, start\fR).VE 8.4.spTcl_UniChar\fBTcl_UniCharAtIndex\fR(\fIsrc, index\fR).VS 8.4.spCONST char *\fBTcl_UtfAtIndex\fR(\fIsrc, index\fR).VE 8.4.spint\fBTcl_UtfBackslash\fR(\fIsrc, readPtr, dst\fR).SH ARGUMENTS.AS "CONST Tcl_UniChar" numChars in/out.AP char *buf outBuffer in which the UTF-8 representation of the Tcl_UniChar is stored.  At mostTCL_UTF_MAX bytes are stored in the buffer..AP int ch inThe Tcl_UniChar to be converted or examined..AP Tcl_UniChar *chPtr outFilled with the Tcl_UniChar represented by the head of the UTF-8 string..AP "CONST char" *src inPointer to a UTF-8 string..AP "CONST Tcl_UniChar" *uniStr inA NULL-terminated Unicode string..AP "CONST Tcl_UniChar" *uniPattern inA NULL-terminated Unicode string..AP int len inThe length of the UTF-8 string in bytes (not UTF-8 characters).  Ifnegative, all bytes up to the first null byte are used..AP int numChars inThe length of the Unicode string in characters.  Must be greater than orequal to 0..AP "Tcl_DString" *dstPtr in/outA pointer to a previously-initialized \fBTcl_DString\fR..AP "unsigned long" num inThe number of characters to compare..AP "CONST char" *start inPointer to the beginning of a UTF-8 string..AP int index inThe index of a character (not byte) in the UTF-8 string..AP int *readPtr outIf non-NULL, filled with the number of bytes in the backslash sequence, including the backslash character..AP char *dst outBuffer in which the bytes represented by the backslash sequence are stored.At most TCL_UTF_MAX bytes are stored in the buffer..VS 8.4.AP int nocase inSpecifies whether the match should be done case-sensitive (0) orcase-insensitive (1)..VE 8.4.BE.SH DESCRIPTION.PPThese routines convert between UTF-8 strings and Tcl_UniChars.  ATcl_UniChar is a Unicode character represented as an unsigned, fixed-sizequantity.  A UTF-8 character is a Unicode character represented asa varying-length sequence of up to TCL_UTF_MAX bytes.  A multibyte UTF-8sequence consists of a lead byte followed by some number of trail bytes..PP\fBTCL_UTF_MAX\fR is the maximum number of bytes that it takes torepresent one Unicode character in the UTF-8 representation..PP\fBTcl_UniCharToUtf\fR stores the Tcl_UniChar \fIch\fR as a UTF-8 stringin starting at \fIbuf\fR.  The return value is the number of bytes storedin \fIbuf\fR..PP\fBTcl_UtfToUniChar\fR reads one UTF-8 character starting at \fIsrc\fRand stores it as a Tcl_UniChar in \fI*chPtr\fR.  The return value is thenumber of bytes read from \fIsrc\fR..  The caller must ensure that thesource buffer is long enough such that this routine does not run off theend and dereference non-existent or random memory; if the source bufferis known to be null terminated, this will not happen.  If the input isnot in proper UTF-8 format, \fBTcl_UtfToUniChar\fR will store the firstbyte of \fIsrc\fR in \fI*chPtr\fR as a Tcl_UniChar between 0x0000 and0x00ff and return 1.  .PP\fBTcl_UniCharToUtfDString\fR converts the given Unicode stringto UTF-8, storing the result in a previously-initialized \fBTcl_DString\fR.You must specify the length of the given Unicode string.The return value is a pointer to the UTF-8 representation of theUnicode string.  Storage for the return value is appended to theend of the \fBTcl_DString\fR..PP\fBTcl_UtfToUniCharDString\fR converts the given UTF-8 string to Unicode,storing the result in the previously-initialized \fBTcl_DString\fR.you may either specify the length of the given UTF-8 string or "-1",in which case \fBTcl_UtfToUniCharDString\fR uses \fBstrlen\fR tocalculate the length.  The return value is a pointer to the Unicoderepresentation of the UTF-8 string.  Storage for the return valueis appended to the end of the \fBTcl_DString\fR.  The Unicode stringis terminated with a Unicode NULL character..PP\fBTcl_UniCharLen\fR corresponds to \fBstrlen\fR for Unicodecharacters.  It accepts a NULL-terminated Unicode string and returnsthe number of Unicode characters (not bytes) in that string..PP\fBTcl_UniCharNcmp\fR and \fBTcl_UniCharNcasecmp\fR correspond to\fBstrncmp\fR and \fBstrncasecmp\fR, respectively, for Unicode characters.They accepts two NULL-terminated Unicode strings and the number of charactersto compare.  Both strings are assumed to be at least \fIlen\fR characterslong. \fBTcl_UniCharNcmp\fR  compares the two strings character-by-characteraccording to the Unicode character ordering.  It returns an integer greaterthan, equal to, or less than 0 if the first string is greater than, equalto, or less than the second string respectively.  \fBTcl_UniCharNcasecmp\fRis the Unicode case insensitive version..PP.VS 8.4\fBTcl_UniCharCaseMatch\fR is the Unicode equivalent to\fBTcl_StringCaseMatch\fR.  It accepts a NULL-terminated Unicode string,a Unicode pattern, and a boolean value specifying whether the match shouldbe case sensitive and returns whether the string matches the pattern..VE 8.4.PP\fBTcl_UtfNcmp\fR corresponds to \fBstrncmp\fR for UTF-8 strings. Itaccepts two NULL-terminated UTF-8 strings and the number of charactersto compare.  (Both strings are assumed to be at least \fIlen\fRcharacters long.)  \fBTcl_UtfNcmp\fR compares the two stringscharacter-by-character according to the Unicode character ordering.It returns an integer greater than, equal to, or less than 0 if thefirst string is greater than, equal to, or less than the second stringrespectively..PP\fBTcl_UtfNcasecmp\fR corresponds to \fBstrncasecmp\fR for UTF-8strings.  It is similar to \fBTcl_UtfNcmp\fR except comparisons ignoredifferences in case when comparing upper, lower or title casecharacters..PP\fBTcl_UtfCharComplete\fR returns 1 if the source UTF-8 string \fIsrc\fRof length \fIlen\fR bytes is long enough to be decoded by\fBTcl_UtfToUniChar\fR, or 0 otherwise.  This function does not guaranteethat the UTF-8 string is properly formed.  This routine is used byprocedures that are operating on a byte at a time and need to know if afull Tcl_UniChar has been seen..PP\fBTcl_NumUtfChars\fR corresponds to \fBstrlen\fR for UTF-8 strings.  Itreturns the number of Tcl_UniChars that are represented by the UTF-8 string\fIsrc\fR.  The length of the source string is \fIlen\fR bytes.  If thelength is negative, all bytes up to the first NULL byte are used..PP\fBTcl_UtfFindFirst\fR corresponds to \fBstrchr\fR for UTF-8 strings.  Itreturns a pointer to the first occurrence of the Tcl_UniChar \fIch\fRin the NULL-terminated UTF-8 string \fIsrc\fR.  The NULL terminator isconsidered part of the UTF-8 string.  .PP\fBTcl_UtfFindLast\fR corresponds to \fBstrrchr\fR for UTF-8 strings.  Itreturns a pointer to the last occurrence of the Tcl_UniChar \fIch\fRin the NULL terminated UTF-8 string \fIsrc\fR.  The NULL terminator isconsidered part of the UTF-8 string.  .PPGiven \fIsrc\fR, a pointer to some location in a UTF-8 string,\fBTcl_UtfNext\fR returns a pointer to the next UTF-8 character in thestring.  The caller must not ask for the next character after the lastcharacter in the string..PPGiven \fIsrc\fR, a pointer to some location in a UTF-8 string,\fBTcl_UtfPrev\fR returns a pointer to the previous UTF-8 character in thestring.  This function will not back up to a position before \fIstart\fR,the start of the UTF-8 string.  If \fIsrc\fR was already at \fIstart\fR, thereturn value will be \fIstart\fR..PP\fBTcl_UniCharAtIndex\fR corresponds to a C string array dereference or thePascal Ord() function.  It returns the Tcl_UniChar represented at thespecified character (not byte) \fIindex\fR in the UTF-8 string\fIsrc\fR.  The source string must contain at least \fIindex\fRcharacters.  Behavior is undefined if a negative \fIindex\fR is given..PP\fBTcl_UtfAtIndex\fR returns a pointer to the specified character (notbyte) \fIindex\fR in the UTF-8 string \fIsrc\fR.  The source string mustcontain at least \fIindex\fR characters.  This is equivalent to calling \fBTcl_UtfNext\fR \fIindex\fR times.  If a negative \fIindex\fR is given,the return pointer points to the first character in the source string..PP\fBTcl_UtfBackslash\fR is a utility procedure used by several of the Tclcommands.  It parses a backslash sequence and stores the properly formedUTF-8 character represented by the backslash sequence in the outputbuffer \fIdst\fR.  At most TCL_UTF_MAX bytes are stored in the buffer.\fBTcl_UtfBackslash\fR modifies \fI*readPtr\fR to contain the numberof bytes in the backslash sequence, including the backslash character.The return value is the number of bytes stored in the output buffer..PPSee the \fBTcl\fR manual entry for information on the valid backslashsequences.  All of the sequences described in the Tcl manual entry aresupported by \fBTcl_UtfBackslash\fR..SH KEYWORDSutf, unicode, backslash

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -