[RESOLVED] [2005] Unicode variable
I'm trying to download few movie names and save it to database. But when I'm reading title from page sourcecode, and there is for eg. french symbol, i have in database something like this: "è" (it works on forum... I have "& # 232;"). How can I get right name?
Code is like this:
Code:
strSource = myClient.DownloadString(strUrl)
strTitle = Functions.GetTitle(strSource)
strTitle = strTitle.Replace("'", "''")
comCommenda.CommandText = "INSERT INTO IMDB_list (Name, Url, [File]) VALUES ('" & strTitle & "','" & strUrl & "','" & strFile & "')"
comCommenda.ExecuteNonQuery()
GetTitle is simple function to get title from source code.
-------------------------------------------------------------
I found, that in source code is "& # 232;" :D
So other question, how to display it in MS Sql 2005 as è ?
Re: [2005] Unicode variable
set datatype of Name column as nvarchar in Database
Re: [2005] Unicode variable
It is nvarchar... I think, in this command sql see text as #&2... not as uniocode.
Re: [2005] Unicode variable
BTW, I think that dowloading content from IMDB and saving it locally is something that they don't encourage. If that's the case, they will probably block your IP after you reach a certain limit of HTTP requests, and they probably will also have ways of doing the same thing if you go through a proxy.
Re: [2005] Unicode variable
I don't care ;) My problem is to get unicode char instead of this numbers.
Re: [2005] Unicode variable
can you post myClient.DownloadString function's code ?
Re: [2005] Unicode variable
It's framework function ;) 'myClient' is Net.WebClient
Re: [2005] Unicode variable
You are downloading the HTML source. & #233; is valid html to display the character è. The browser does the rendering when you view the content. You will need to convert it in your code.
You can use the System.Web.HttpUtility.HtmlDecode function:
Code:
' Remove the space to see the example, the forums automatically converted it if I take the space out
Dim s As String = "t& #233;st"
MessageBox.Show(System.Web.HttpUtility.HtmlDecode(s))
Re: [2005] Unicode variable
Thanks!
One thing: "HttpUtility is not a member of 'Web'"... It's member of?
Re: [2005] Unicode variable
Make sure you add a reference to System.Web in your project.
Re: [2005] Unicode variable
Ouh, you right ;) Thanks, again!