character encoding problems

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • samsinfield
    New Member
    • Mar 2012
    • 1

    character encoding problems

    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.CreateComm and();
    cmd.CommandType = CommandType.Sto redProcedure;
    cmd.CommandText = "sp_RetrievePag e";

    SqlParameter parInput = cmd.Parameters. Add("@pageId",S qlDbType.Unique Identifier);
    parInput.Value = pageId;


    conn.Open();
    using (SqlDataReader dr = cmd.ExecuteRead er())
    {
    while (dr.Read()){
    string pagecontent = dr.IsDBNull(dr. GetOrdinal("pag econtent")) ? "" : dr.GetString(dr .GetOrdinal("pa gecontent"));
    }
    }

    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?????
Working...