+ Reply to Thread
Results 1 to 6 of 6

Thread: UTF-8 and MSSQL

  1. #1
    Join Date
    Jun 2005
    Location
    Tunbridge Wells, Kent
    Posts
    189
    Thanks
    5
    Thanked 0 Times in 0 Posts
    Gamer IDs

    Gamertag: UrbanDirt

    Default UTF-8 and MSSQL

    Afternoon.

    I'm working on a custom VB.Net cms working with an MS SQL database.

    The web.config is ensuring globalization is UTF-8, the .net page is ensuring UTF-8, the html tag is ensuring UTF-8...

    My problem is the recent addition of Polish pages, and Polish characters!

    The web page is delivering the correct special polish characters after submission when I run a quick response.write - BUT! (here it is) the characters are not being saved into the database...

    any ideas?

  2. #2
    Join Date
    Mar 2005
    Location
    Hampshire
    Posts
    431
    Thanks
    4
    Thanked 3 Times in 3 Posts
    Gamer IDs

    Gamertag: De Mote

    Default

    Is the field that the data is being saved into a varchar or nvarchar. As a varchar will only store ansii standard character. Make sure that you are using nvarchar to store this type of data.

    Just chill

  3. #3
    Join Date
    Jun 2005
    Location
    Tunbridge Wells, Kent
    Posts
    189
    Thanks
    5
    Thanked 0 Times in 0 Posts
    Gamer IDs

    Gamertag: UrbanDirt

    Default

    I'm storing as ntext... as it's an HTML editor text box from a CMS system.

    Perhaps it's worth changing to an nvarchar with a large amount of characters?

    Other forums show:

    NVARCHAR uses 2-byte characters so only half the "max" data (4000 vs 8000) characters can be stored. If you must support UTF-8 character sets, NVARCHAR is the way to go. If not, stick with VARCHAR for single-character character sets.

    Unforunately! As it's an HTML editor text box, one of the entries exceeds 5000 characters! nvarchar isn't an immediate solution.

    Perhaps a function changing all special characters to their UTF-8 code?!

  4. #4
    Join Date
    Feb 2004
    Posts
    4,564
    Thanks
    2
    Thanked 94 Times in 86 Posts

    Default

    NTEXT should be fine, what about the SQL connection - is that definitely being made with a UTF8 charset (try running a simple SELECT 'POLISH TEXT HERE' to see what comes back)?
    Warren Ashcroft
    Red Fox UK Limited - Pioneers in Internet Technology
    http://www.redfoxuk.com
    w.ashcroft [at] redfoxuk.com

    NOTE: Forum Private Messaging should not be used to contact staff with support queries.

  5. #5
    Join Date
    May 2007
    Location
    Eauze, France
    Posts
    143
    Thanks
    10
    Thanked 16 Times in 14 Posts

    Default

    I am using varchar and European character sets (that I use - mainly french) seems to work fine.

    I do however include following on pages which can contain non standard characters .

    Response.CharSet = "utf-8"
    Response.CodePage = 65001

    See
    http://support.microsoft.com/kb/232580


    David.

  6. #6
    Join Date
    Jan 2006
    Posts
    418
    Thanks
    2
    Thanked 16 Times in 16 Posts

    Default

    Hi,

    NText should be find - if you were using sql 2005 i would suggest nvarchar(max).

    The following statements I would omit

    Response.CharSet = "utf-8"
    Response.CodePage = 65001

    But ensure that the following is present in the head section of the page

    <meta http-equiv="content-type" content="text/html; charset=UTF-8" />

    James

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Similar Threads

  1. Php + Mssql
    By albatroz in forum PHP
    Replies: 2
    Last Post: 19th September 2006, 06:01 PM
  2. Mssql Structure
    By creativeworks in forum MSSQL
    Replies: 1
    Last Post: 2nd April 2006, 01:38 PM
  3. MSSQL Setup
    By Pete Furness in forum Technical Support
    Replies: 3
    Last Post: 18th January 2006, 07:07 PM
  4. A Couple Of MSSQL Questions
    By Richard Murrant in forum Sales and Service Feature Enquiries
    Replies: 3
    Last Post: 7th July 2005, 08:21 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts