By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,950 Members | 1,005 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,950 IT Pros & Developers. It's quick & easy.

character encoding problems

P: 1
Hi,

I have a mssql db table that stores html content in an nvarchar(max) field, a stored procedure that retrieves the content. A legacy dotnet 1.1 app that has a class that executes the stored procedure to retrieve the HTML data.
The customer has started adding Welsh pages and I have a field that contains the ŵ (w with a circumflex) character.
When the data is retrieved from an admin page, the character is displayed correctly but when the html content is shown on the front end, it has been changed to a w (circumflex removed).
I've stepped through the code from the front end and when it gets to the method that calls the stored procedure, the character is reverted to a w as soon as it comes from the database.

When I step through the code from the admin page, the character is retrieved from the db correctly


The stored procedure is simply
select * from pages where pageid=@pageId

and the code that calls the stored procedure is:
SqlCommand cmd = conn.CreateCommand();
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "sp_RetrievePage";

SqlParameter parInput = cmd.Parameters.Add("@pageId",SqlDbType.UniqueIdent ifier);
parInput.Value = pageId;


conn.Open();
using (SqlDataReader dr = cmd.ExecuteReader())
{
while (dr.Read()){
string pagecontent = dr.IsDBNull(dr.GetOrdinal("pagecontent")) ? "" : dr.GetString(dr.GetOrdinal("pagecontent"));
}
}

machine.config has globalization set to utf-8 and so does the web.config.

I'm at a loss as to why the character is being altered to w on one page and stays as ŵ on another within the same application.
If I execute the stored procedure directly in sql management studio, it displays the characte correcly, as ŵ

Can anyone please help?????
Mar 14 '12 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.