ConvertEncoding Function

Provides a quick way to convert a string of known encoding to some other encoding, without having to create a TextConverter object.

Syntax

result = ConvertEncoding( str, newEncoding )

result = Str.ConvertEncoding( newEncoding )


Parameters

str

String

The string to be converted.

newEncoding

TextEncoding

The encoding to be used in the conversion.



Notes

When you need to write text to a file that will be opened by another application that expects a particular encoding, use ConvertEncoding to convert the text to that encoding before you call the Write method. Here is an example that converts the text in an EditField to the MacRoman encoding.

Dim file As FolderItem
Dim fileStream As TextOutputStream
file=GetSaveFolderItem("plain/text","My Info")
fileStream=file.CreateTextFile
fileStream.Write ConvertEncoding(namefield.Text, Encodings.MacRoman)
fileStream.Close

Example

The following example use the Encodings object to convert the text in an EditField to the ANSI encoding

Dim s as String
s=ConvertEncoding(Editfield1.text,Encodings.WindowsANSI)

.


See Also

TextConverter, TextEncoding, TextOutputStream classes; DefineEncoding, Encoding functions; Encodings object.