Help on char or string var...but some unicode

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • gorostas

    #1

    Help on char or string var...but some unicode

    Helo everyone!

    I'm making some little app whitch will help me to get things automated,,,im
    in the need very often to make some little changes to some files, and
    something like this:

    dim string1
    dim string2
    dim temp

    temp=string1
    string1=sting2
    sting2=temp

    now, my procedure is taking every file, open it, do some changes and save
    it!
    but i loos my characters. Im from Croatia (EU) and have some chars like
    |Щ®ÆÈ|...how can i save in unicode file type.

    my code is:
    =============== ===============

    Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As
    System.EventArg s) Handles Button1.Click
    If Label4.Text = "" Then
    MsgBox("izaberi putanju prvo")
    Exit Sub
    End If

    If TextBox1.Text = "" Then
    MsgBox("Unesi barem nesto u gornje polje!")
    Exit Sub
    End If

    Dim putanja As String = StatusBar1.Text & "\"
    Dim dirinfo As DirectoryInfo
    Dim niz As Array
    Dim dir As Array
    Dim filinf As FileInfo
    Dim a As Int16 = 0
    Dim tee As String

    dirinfo = New DirectoryInfo(p utanja)
    niz = dirinfo.GetFile s("*." & TextBox3.Text)
    dir = dirinfo.GetDire ctories()

    For Each filinf In niz
    temp_string.Tex t = " "
    temp_string.Ref resh()
    Dim sr As StreamReader = New StreamReader(pu tanja & filinf.Name)
    Label5.Text = filinf.Name
    Label5.Refresh( )
    temp_string.Tex t = sr.ReadToEnd
    sr.Close()
    temp_string.Sel ectAll()
    Dim index As Integer = temp_string.Tex t.IndexOf(TextB ox1.Text)
    While index >= 0
    temp_string.Sel ect(index, TextBox1.TextLe ngth)
    temp_string.Sel ectedText = TextBox2.Text
    index = temp_string.Tex t.IndexOf(TextB ox1.Text, index + 1)
    a += 1
    End While
    If a > 1 Then
    MsgBox("nadjena je rijec!")
    End If
    Label9.Text = a
    tee = temp_string.Tex t

    'temp_string.Sa veFile(putanja & filinf.Name)

    Dim sw As StreamWriter = New StreamWriter(pu tanja & filinf.Name)
    sw.Write(tee)
    sw.Flush()
    sw.Close()

    Next
    End Sub

    =============== ===============

    thanks in advance



    -k.p.


  • Cor Ligthert

    #2
    Re: Help on char or string var...but some unicode

    Gorostas,

    When I saw it well, than you set the information intermidiate in a textbox.
    When your file is in a code table, that the computer cannot handle, then
    some unicodecharacte rs will be lost.

    This is in the configurations of your computer advanced coutry settings.

    Latest news coverage, email, free stock quotes, live scores and video are just the beginning. Discover more every day at Yahoo!


    I hope this helps,

    Cor


    Comment

    • Herfried K. Wagner [MVP]

      #3
      Re: Help on char or string var...but some unicode

      "gorostas" <gorostasREMOVE _THIS@hotmail.c om> schrieb:[color=blue]
      > now, my procedure is taking every file, open it, do some changes and save
      > it!
      > but i loos my characters. Im from Croatia (EU) and have some chars like
      > |Щ®ÆÈ|...how can i save in unicode file type.
      >[...]
      > Dim sw As StreamWriter = New StreamWriter(pu tanja &
      > filinf.Name)[/color]

      '... = New StreamWriter(.. ., System.Text.Enc oding.Unicode)' . Maybe the
      UTF-8 encoding is sufficient ('Encoding.UTF8 ').

      --
      M S Herfried K. Wagner
      M V P <URL:http://dotnet.mvps.org/>
      V B <URL:http://classicvb.org/petition/>

      Comment

      • gorostas

        #4
        Re: Help on char or string var...but some unicode

        Thanx Cor, but my computer is configured ok whit my language and other
        country settings.


        "Cor Ligthert" <notmyfirstname @planet.nl> wrote in message
        news:OWK3$%23gY FHA.2884@tk2msf tngp13.phx.gbl. ..
        | Gorostas,
        |
        | When I saw it well, than you set the information intermidiate in a
        textbox.
        | When your file is in a code table, that the computer cannot handle, then
        | some unicodecharacte rs will be lost.
        |
        | This is in the configurations of your computer advanced coutry settings.
        |
        | http://www.geocities.com/Athens/Acad...ph/fontset.htm
        |
        | I hope this helps,
        |
        | Cor
        |
        |


        Comment

        • gorostas

          #5
          Re: Help on char or string var...but some unicode

          Thanx Herfried, and yes UTF-8 is sufficient for everyone.
          I putted breakpoint in my app and see that is streamwriting in
          UTF-8....

          and i dont know why cant i see my characters??

          im opening *.asp and *.aspx files. If that can help someone.
          i tried to open some othet *.txt files whitch i saved whit 'notepad'
          and everything goes well-....very confusing"!"!

          thanks all


          "Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> wrote in message
          news:OTIdXFhYFH A.1412@TK2MSFTN GP12.phx.gbl...
          | "gorostas" <gorostasREMOVE _THIS@hotmail.c om> schrieb:
          | > now, my procedure is taking every file, open it, do some changes and
          save
          | > it!
          | > but i loos my characters. Im from Croatia (EU) and have some chars like
          | > |Щ®ÆÈ|...how can i save in unicode file type.
          | >[...]
          | > Dim sw As StreamWriter = New StreamWriter(pu tanja &
          | > filinf.Name)
          |
          | '... = New StreamWriter(.. ., System.Text.Enc oding.Unicode)' . Maybe the
          | UTF-8 encoding is sufficient ('Encoding.UTF8 ').
          |
          | --
          | M S Herfried K. Wagner
          | M V P <URL:http://dotnet.mvps.org/>
          | V B <URL:http://classicvb.org/petition/>
          |


          Comment

          Working...