Subject:Removing Smart Qoutes
Posted by: RC_Intel
Date:3/20/2006 7:48:52 AM
I have a form that allows my users to enter summary information about the sound clip and then saves that information in the ForgeApp.CurrentFile.Summary.Comments section. Sometimes the user pastes text from MS Word that contains Smart Quotes into the form, I want to replace the Smart Quotes with regular ' or ". I wrote the following and it works in .Net but not in Sound Forge, any ideas? string tmp = txtTopic1.Text.Trim(); tmp = tmp.Replace(Convert.ToChar("‘"), '\''); tmp = tmp.Replace(Convert.ToChar("’"), '\''); tmp = tmp.Replace(Convert.ToChar("“"), '\"'); tmp = tmp.Replace(Convert.ToChar("”"), '\"'); The error I get is "String must be only one character long." at System.Convert.ToChar(String value). Yet this code works just fine in .Net 1.1 and 2.0 Thanks |
Subject:RE: Removing Smart Qoutes
Reply by: RC_Intel
Date:3/20/2006 12:48:00 PM
Never mind. If I change the script to: tmp = tmp.Replace(Convert.ToChar("\u2018"), '\''); tmp = tmp.Replace(Convert.ToChar("\u2019"), '\''); tmp = tmp.Replace(Convert.ToChar("\u201c"), '\"'); tmp = tmp.Replace(Convert.ToChar("\u201d"), '\"'); It works just fine. |
Subject:RE: Removing Smart Qoutes
Reply by: _TJ
Date:3/20/2006 1:16:58 PM
It could be the encoding in the source files. By default, Sound Forge saves script files encoded as ANSI if all of the characters in the file fit in the ANSI codepage, if not then it saves the file encoded as UTF8. (UTF8 is an 8 bit codepage that maps easily in and out of Unicode). It's possible that whatever is inside the quotes in your script. (lost when you pasted into this forum) is getting converted into a 2 character sequence in the UTF8 codepage, which the compiler doesn't like. Saving your script as a UNICODE text file would solve this problem. But you would have to do that outside of Sound Forge, and then run the script from the Script Menu. Or you could make your script not dependend on the encoding by using the \uNNNN method for specifying unicode codepoints inside ANSI strings. tj Message last edited on3/20/2006 7:38:15 PM by_TJ. |