UtterAccess HomeUtterAccess Wiki

Welcome Guest ( Log In | Register )

Custom Search
Edit Discussion
> ToXmlHex    
CODE

'---------------------------------------------------------------------------------------------------------------------------------------
' ToXmlHex
' http://www.utteraccess.com/wiki/index.php/FunctionNameHere
' Code courtesy of UtterAccess Wiki
' Original submission by Diego F.Pereira-Perdomo
' Licensed under Creative Commons License
' http://creativecommons.org/licenses/by-sa/3.0/
'
' You are free to use this code in any application,
' provided this notice is left unchanged.
'
' rev  date                          brief descripton
' 1.0  2012-07-10                    Transforms a string in a Hex entity "_x###$_"
'---------------------------------------------------------------------------------------------------------------------------------------
Public Function ToXmlHex(strChar As String)

On Error GoTo ErrorHandler

Dim l       As Integer
Dim i       As Integer
Dim Char    As String
Dim strXML  As String

l = Len(strChar)

For i = 1 To l
   Char = Mid(strChar, i, 1)
   If Len(Hex(Asc(Char))) = 2 Then
       strXML = strXML & "_x00" & Hex(Asc(Char)) & "_"
   ElseIf Len(Hex(Asc(Char))) = 3 Then
       strXML = strXML & "_x0" & Hex(Asc(Char)) & "_"
   ElseIf Len(Hex(Asc(Char))) = 4 Then
       strXML = strXML & "_x" & Hex(Asc(Char)) & "_"
   End If
Next i

ToXmlHex = strXML

ErrorHandler:
Select Case Err.Number
   Case 0
   Case Else
       MsgBox Err.Number & ": " & Err.Description
End Select
End Function

Creative Commons License
ToXmlHex by UtterAccess Wiki is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Editing and revision of the content is freely encouraged; for details, see Expected Usage.

Edit Discussion
Custom Search
Thank you for your support!
This page has been accessed 1,999 times.  This page was last modified 06:46, 10 July 2012 by dipetete.   Disclaimers