writing cute editor text to sql db creates unrecognizable characters.

Last post 06-05-2008, 4:19 AM by AndyFel. 7 replies.
Sort Posts: Previous Next
  •  05-30-2008, 12:27 PM 40943

    writing cute editor text to sql db creates unrecognizable characters.

     Our implementation of cute editor writes the text to a sql db, if I look at the data stored in sql it seems like any line break creates some unrecognizable characters, as well as the correct <br /> or <p> tags.  When I try to use the data in sql in another app. it doesn't work out that well because of the unrecognizable characters.  
     
    The sql column datatype is varchar.  
     
    I have read something about Server.Encoding/Decoding, but I am fairly new to this and would need to be walked through this if that is a possible solution.
     
    Any help would be much appreciated.
     
    Thanks.
  •  05-30-2008, 1:25 PM 40945 in reply to 40943

    Re: writing cute editor text to sql db creates unrecognizable characters.

    rob99999,
     
    Did you encode the string when saveing the content into DB?
     
    Can you try this example?
     
     
    The source code of this example is included in the download package.
     
    Keep me posted

    asp.net Chat http://cutesoft.net/ASP.NET+Chat/default.aspx
    Web Messenger: http://cutesoft.net/Web-Messenger/default.aspx
    asp.net wysiwyg editor: http://cutesoft.net/ASP.NET+WYSIWYG+Editor/default.aspx
    asp wysiwyg html editor: http://cutesoft.net/ASP
    asp.net Image Gallery: http://cutesoft.net/ASP.NET+Image+Gallery/default.aspx
    Live Support: http://cutesoft.net/live-support/default.aspx

  •  06-03-2008, 9:33 PM 41060 in reply to 40945

    Re: writing cute editor text to sql db creates unrecognizable characters.

    Hi Adam,
    Thanks for the example. 
     
    After taking a look at HTML encode we added.
    Server.HtmlEncode(CEDescription.Text.Trim)
    That seems to encode the text to HTML but the unrecogizable characters remain in the sql db.
     
     
    I type this into the editor text box: (the line breaks are by pressing enter)
     theyyeyheh
    djdjjdjdjdjdj
    dgdgdg


    ssssss
     
    The sql db has this stored:
     
    when my flash app calls this it gets extra breaks where there are those unrecognizable characters...
     
    Any info would be helpful.
    Thanks,
    Rob
     
     
  •  06-04-2008, 12:28 AM 41064 in reply to 41060

    Re: writing cute editor text to sql db creates unrecognizable characters.

    Rob,
     
    I have no idea where those characters come from.
     
    Do you try this example?
     
     
    If you don't have problems with it, please try this example in you local machine.
     
    Keep me posted

    asp.net Chat http://cutesoft.net/ASP.NET+Chat/default.aspx
    Web Messenger: http://cutesoft.net/Web-Messenger/default.aspx
    asp.net wysiwyg editor: http://cutesoft.net/ASP.NET+WYSIWYG+Editor/default.aspx
    asp wysiwyg html editor: http://cutesoft.net/ASP
    asp.net Image Gallery: http://cutesoft.net/ASP.NET+Image+Gallery/default.aspx
    Live Support: http://cutesoft.net/live-support/default.aspx

  •  06-04-2008, 8:31 AM 41103 in reply to 41064

    Re: writing cute editor text to sql db creates unrecognizable characters.

    Hi
     
    The square things are just enterprise managers way of showing CR and LF. What other apps are you trying to use the data in?
    If you do a select statement in sql manager and show the results as text, does the text look properly formatted? It should do...
     
    When saving and retrieving from the database I dont do any encoding/decoding. I just send a string and get a string and its all shown fine.
     
    You may want to consider using NVarchar instead of Varchar because this then means you can store characters outside the standard ascii range e.g. different character sets or symbols. But these will still be shown as squares in sql manager.
     
     
  •  06-04-2008, 1:57 PM 41126 in reply to 41103

    Re: writing cute editor text to sql db creates unrecognizable characters.

    Hi AndyFel,
     
    Thanks much, for taking the time.

    - The query results in default sql server grid don't show the boxes (as you suggested wouldn't happen), but there are spaces in between. 
    so it looks like:  asd<br />  asd<br />  asd<br />  <br />
     
    - The query resutls to text look like the following:
     
     
     
     
    - If I remove the CR and LF boxes manually by editting the table in Ent. Manager (man. studio) the text displays perfectly when I query from sql server (no spaces) and as well in the flash application that is grabbing data from the database.
     
    - I switched the column datatype to nvarchar as suggested - but no change for me here.
     
    - Any info on how to remove the CR and LF boxes? or possibly any other ideas?
     
    Thanks again to Adam and AndyFel for there continued help, 
     
    Rob
  •  06-04-2008, 9:14 PM 41132 in reply to 41126

    Re: writing cute editor text to sql db creates unrecognizable characters.

    Hi all,
     
    Looks like a REPLACE did the trick for us.  
     
    CEDescription.Text.Trim.Replace(vbCrLf, "").Replace(Environment.NewLine, "")
     
    After looking at some sql server posts, I guess its pretty common for CR and LF to get combined and turned into some SQUARE character display in the database. 
     
    Thanks to all those who helped out.  Hope this helps someone else along the way.
     
    Rob 
  •  06-05-2008, 4:19 AM 41147 in reply to 41132

    Re: writing cute editor text to sql db creates unrecognizable characters.

    Hi
     
    Yep replace would do the trick but you have now lost all your newline formatting. So if you come to edit the html again all the text would be one one line.
     
    It may be better to do the replace when you suck the data out of the DB for the flash, and leave it if you are trying to edit it again.
     
    The Nvarchar column wouldnt of helped in this case, it just means you can store non standard chars and get them out again.
     
    Glad its working anyway.
     
    Andy
View as RSS news feed in XML