Danh mục tài liệu

Các hàm UNICODE thông dụng

Số trang: 6      Loại file: pdf      Dung lượng: 102.59 KB      Lượt xem: 23      Lượt tải: 0    
Xem trước 2 trang đầu tiên của tài liệu này:

Thông tin tài liệu:

Đổi chữ thường thành chữ hoa: Function UpperUniChar(Ch) As String Return the Uppercase for a given vowel or dd Dim Pos Position of character in Unicode vowel list Locate the character in list of Unicode vowels Pos = InStr(UVowels, Ch) If (Pos 67) Then UpperUniChar = Ch Its already uppercase - leave it alone ElseIf (Pos 0) Then Its a Lowercase Unicode Vowel - so get the corresponding Uppercase vowel in the list UpperUniChar = Mid(UVowels, Pos + 67, 1) Else Its just a normal ANSI character UpperUniChar = UCase(Ch) End If...
Nội dung trích xuất từ tài liệu:
Các hàm UNICODE thông dụng Các hàm UNICODE thông d ụngĐổi chữ thường thành chữ hoa:Function UpperUniChar(Ch) As String Return the Uppercase for a given vowel or dd Dim Pos Position of character in Unicode vowel list Locate the character in list of Unicode vowels Pos = InStr(UVowels, Ch) If (Pos > 67) Then UpperUniChar = Ch Its already uppercase - leave it alone ElseIf (Pos > 0) Then Its a Lowercase Unicode Vowel - so get the corresponding Uppercasevowel in the list UpperUniChar = Mid(UVowels, Pos + 67, 1) Else Its just a normal ANSI character UpperUniChar = UCase(Ch) End IfEnd FunctionĐọc Text UNICODE từ filePublic Function ReadTextFile(FileName) As String Write a Unicode String to UTF-16LE Text file Remember to Project | References Microsoft Scripting Runtime to support FileSystemObject & TextStream Dim Fs As FileSystemObject Dim TS As TextStream Create a FileSystem Object Set Fs = CreateObject(Scripting.FileSystemObject) Open TextStream for Input. TriStateTrue means Read Unicode UTF-16LE Set TS = Fs.OpenTextFile(FileName, ForReading, False, TristateTrue) ReadTextFile = TS.ReadAll Read the whole content of the text file in onestroke TS.Close Close the Text Stream Set Fs = Nothing Dispose FileSystem ObjectEnd FunctionViết UNICODE text ra filePublic Sub WriteTextFile(FileName, StrOutText) Read a Unicode String from UTF-16LE Text file Remember to Project | References Microsoft Scripting Runtime to support FileSystemObject & TextStream Dim Fs As FileSystemObject Dim TS As TextStream Create a FileSystem Object Set Fs = CreateObject(Scripting.FileSystemObject) Open TextStream for Output, create file if necesssary TriStateTrue means Write Unicode UTF-16LE Set TS = Fs.OpenTextFile(File Name, ForWriting, True, TristateTrue) TS.Write StrOutText Write the whole StrOutText string in one stroke TS.Close Close the Text Stream Set Fs = Nothing Dispose FileSystem ObjectEnd SubCách gọn và tiện nhất để đọc và viết UTF-8 text files là dùng m ột VB6 Classtên clsUnicodeText d ựa vào MS DOM (Document Object Model) và XML nhưsau:Dim MyUnicodeText As clsUnicodeTextSet MyUnicodeText = New clsUnicodeText Read Unicode Text from file txtFileName and display in TextBox1TextBox1.Text = MyUnicodeText.ReadUnicode(txtFileName)Listing của Class clsUnicodeText nh ư sau:Option ExplicitPrivate mDOMTextFile As DOMDocumentPrivate mXMLPath As StringPublic Function ReadUnicode(TXMLPat h) Dim objTextFileRoot As IXMLDOMElement Set mDOMTextFile = New DOMDocument mXMLPath = TXMLPath mDOMTextFile.Load mXMLPath start at the root element of the XML Set objTextFileRoot = mDOMTextFile.documentElement ReadUnicode = objTextFileRoot. nodeTypedValueEnd FunctionPublic Sub WriteUnicode(OutText, Optional TXMLPath) Dim tDOMNode As IXMLDOMElement Temporary Node for DOM If IsMissing(TXMLPath) Then Save the information on the screen by creating a new element and add itschildren to the DOM object mDOMTextFile.documentElement.Text = OutText Update the XML file mDOMTextFile.save mXMLPath Else Set mDOMTextFile = New DOMDocument Create a Node called Text in DOM Set tDOMNode = mDOMTextFile.createElement(Text) Make it the Root Node mDOMTextFile.appendChild tDOMNode Assign Output Text to Root Node mDOMTextFile.documentElement.Text = OutText Update the XML file mDOMTextFile.save TXMLPath End IfEnd SubNguồn: Vovisoft{/tab}

Tài liệu được xem nhiều:

Tài liệu có liên quan: