ConvertCharset Method


Converts the supplied string encoded in the given charset into another charset.

If you simply need to output certain string in UTF-8 encoding, use ToUTF8 method. The sample code in this topic emulates the effect of ToUTF8 via calling ConvertCharset method.


strConverted = ObjectName.ConvertCharset(Src, SrcCharset, DestCharset)
 
Parameters:  
Src As String The source string encoded in SrcCharset.  
SrcCharset As String The charset encoding of the source string. If an empty string, it's assumed that Src is not encoded (i.e. it's Unicode).  
DestCharset As String The charset encoding of the output string. If an empty string, it's assumed that the output should be Unicode (i.e. it's not encoded).  
Return value As String The converted string, or the same string if both SrcCharset and DestCharset are empty strings.  

Usage example:

Dim Mailer
'Using visual basic to create object
Set Mailer = CreateObject("MailBee.SMTP")
'Using ASP to create object
'Set Mailer = Server.CreateObject("MailBee.SMTP")
'In ASP use Response.Write instead of MsgBox
Mailer.LicenseKey = "put your license key here"
Mailer.ServerName = "mail.server.com"
If Mailer.Connect Then
  Mailer.Message.ToAddr = "bill@yoursite.com"
  Mailer.Message.FromAddr = "joe@mysite.com"
  Mailer.Message.Subject = "International message"
  'Inform mail readers that the body contains UTF-8 data
  Mailer.Message.Charset = "utf-8"
  'Produce UTF-8 body
  Mailer.Message.BodyText = Mailer.Message.ConvertCharset("text with int. chars", "", "utf-8")
  Mailer.Send
  Mailer.Disconnect
End If

See Also:

Charset Property


Copyright © 2002-2021, AfterLogic Corporation. All rights reserved.