I need to convert UTF8 string to ISO-8859-1 string using VB.NET.
Any example?
emphasized textI have tried Latin function and not runs. I recei
Dont know if this should be posted here but i made a small function in C# to check if a string support the target encoding type.
Hope it can be of any help...
///
/// Function for checking if a string can support the target encoding type
///
/// The text to check
/// The target encoding
/// True if the encoding supports the string and false if it does not
public bool SupportsEncoding(string text, Encoding targetEncoding)
{
var btext = Encoding.Unicode.GetBytes(text);
var bencodedtext = Encoding.Convert(Encoding.Unicode, targetEncoding, btext);
var checktext = targetEncoding.GetString(bencodedtext);
return checktext == text;
}
//Call the function demo with ISO-8859-1/Latin-1
if (SupportsEncoding("some text...", Encoding.GetEncoding("ISO-8859-1")))
{
//The encoding is supported
}
else
{
//The encoding is not supported
}