To convert string input to ascii or ansi character encoding in dotnet following function can be used. Just call the function and pass the string variable and get the ansi or ascii encoding. The problem I was facing was although I was getting the value in regional language character but it was getting displayed in machine language. I got those character in a string variable and called this function. Whatever is returned from the funtion is inturn pushed to database.
public string GetAnsiCharacter(string stringVariable)
{
Byte[] byteString= System.Text.Encoding.Default.GetBytes(stringVariable);
return System.Text.UTF8Encoding.UTF8.GetString(byteString);
}

No comments:
Post a Comment