Results 1 to 11 of 11

Thread: [RESOLVED] [2005] Unicode variable

  1. #1

    Thread Starter
    Hyperactive Member Ivenesco's Avatar
    Join Date
    Sep 2007
    Location
    Poland, Lublin
    Posts
    325

    Resolved [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;"
    So other question, how to display it in MS Sql 2005 as è ?
    Last edited by Ivenesco; Jul 17th, 2008 at 12:03 PM.
    "Only two things are infinite; the universe and human stupidity, and I'm not sure about the former."
    Albert Einstein

  2. #2
    Frenzied Member
    Join Date
    Jan 2006
    Posts
    1,875

    Re: [2005] Unicode variable

    set datatype of Name column as nvarchar in Database
    __________________
    Rate the posts that helped you

  3. #3

    Thread Starter
    Hyperactive Member Ivenesco's Avatar
    Join Date
    Sep 2007
    Location
    Poland, Lublin
    Posts
    325

    Re: [2005] Unicode variable

    It is nvarchar... I think, in this command sql see text as #&2... not as uniocode.
    "Only two things are infinite; the universe and human stupidity, and I'm not sure about the former."
    Albert Einstein

  4. #4
    Frenzied Member ntg's Avatar
    Join Date
    Sep 2004
    Posts
    1,449

    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.
    "Feel the force...read the source..."
    Utilities: POPFileDebugViewProcess ExplorerWiresharkKeePassUltraVNCPic2Ascii
    .Net tools & open source: DotNetNukelog4NetCLRProfiler
    My open source projects: Thales SimulatorEFT CalculatorSystem Info ReporterVSS2SVNIBAN Functions
    Customer quote: "If the server has a RAID array, why should we bother with backups?"
    Programmer quote: "I never comment my code. Something that is hard to write should be impossible to comprehend."
    Ignorant quote: "I have no respect for universities, as they teach not practicle stuff, and charge money for"

  5. #5

    Thread Starter
    Hyperactive Member Ivenesco's Avatar
    Join Date
    Sep 2007
    Location
    Poland, Lublin
    Posts
    325

    Re: [2005] Unicode variable

    I don't care My problem is to get unicode char instead of this numbers.
    "Only two things are infinite; the universe and human stupidity, and I'm not sure about the former."
    Albert Einstein

  6. #6
    Frenzied Member
    Join Date
    Jan 2006
    Posts
    1,875

    Re: [2005] Unicode variable

    can you post myClient.DownloadString function's code ?
    __________________
    Rate the posts that helped you

  7. #7

    Thread Starter
    Hyperactive Member Ivenesco's Avatar
    Join Date
    Sep 2007
    Location
    Poland, Lublin
    Posts
    325

    Re: [2005] Unicode variable

    It's framework function 'myClient' is Net.WebClient
    "Only two things are infinite; the universe and human stupidity, and I'm not sure about the former."
    Albert Einstein

  8. #8
    PowerPoster 2.0 Negative0's Avatar
    Join Date
    Jun 2000
    Location
    Southeastern MI
    Posts
    4,367

    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))

  9. #9

    Thread Starter
    Hyperactive Member Ivenesco's Avatar
    Join Date
    Sep 2007
    Location
    Poland, Lublin
    Posts
    325

    Re: [2005] Unicode variable

    Thanks!
    One thing: "HttpUtility is not a member of 'Web'"... It's member of?
    Last edited by Ivenesco; Jul 17th, 2008 at 01:27 PM.
    "Only two things are infinite; the universe and human stupidity, and I'm not sure about the former."
    Albert Einstein

  10. #10
    PowerPoster 2.0 Negative0's Avatar
    Join Date
    Jun 2000
    Location
    Southeastern MI
    Posts
    4,367

    Re: [2005] Unicode variable

    Make sure you add a reference to System.Web in your project.

  11. #11

    Thread Starter
    Hyperactive Member Ivenesco's Avatar
    Join Date
    Sep 2007
    Location
    Poland, Lublin
    Posts
    325

    Re: [2005] Unicode variable

    Ouh, you right Thanks, again!
    "Only two things are infinite; the universe and human stupidity, and I'm not sure about the former."
    Albert Einstein

Posting Permissions

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



Click Here to Expand Forum to Full Width