469,342 Members | 5,699 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,342 developers. It's quick & easy.

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(ByVal sender As System.Object, ByVal e As
System.EventArgs) 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(putanja)
niz = dirinfo.GetFiles("*." & TextBox3.Text)
dir = dirinfo.GetDirectories()

For Each filinf In niz
temp_string.Text = " "
temp_string.Refresh()
Dim sr As StreamReader = New StreamReader(putanja & filinf.Name)
Label5.Text = filinf.Name
Label5.Refresh()
temp_string.Text = sr.ReadToEnd
sr.Close()
temp_string.SelectAll()
Dim index As Integer = temp_string.Text.IndexOf(TextBox1.Text)
While index >= 0
temp_string.Select(index, TextBox1.TextLength)
temp_string.SelectedText = TextBox2.Text
index = temp_string.Text.IndexOf(TextBox1.Text, index + 1)
a += 1
End While
If a > 1 Then
MsgBox("nadjena je rijec!")
End If
Label9.Text = a
tee = temp_string.Text

'temp_string.SaveFile(putanja & filinf.Name)

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

Next
End Sub

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

thanks in advance

-k.p.
Nov 21 '05 #1
4 1192
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 unicodecharacters 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
Nov 21 '05 #2
"gorostas" <go*****************@hotmail.com> 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(putanja &
filinf.Name)


'... = New StreamWriter(..., System.Text.Encoding.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/>

Nov 21 '05 #3
Thanx Cor, but my computer is configured ok whit my language and other
country settings.
"Cor Ligthert" <no************@planet.nl> wrote in message
news:OW****************@tk2msftngp13.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 unicodecharacters 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
|
|
Nov 21 '05 #4
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]" <hi***************@gmx.at> wrote in message
news:OT**************@TK2MSFTNGP12.phx.gbl...
| "gorostas" <go*****************@hotmail.com> 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(putanja &
| > filinf.Name)
|
| '... = New StreamWriter(..., System.Text.Encoding.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/>
|
Nov 21 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

8 posts views Thread by Duncan Winn | last post: by
14 posts views Thread by Nick Z. | last post: by
1 post views Thread by Rahul | last post: by
4 posts views Thread by WaterWalk | last post: by
4 posts views Thread by Robin Haswell | last post: by
1 post views Thread by Simon Posnjak | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
1 post views Thread by haryvincent176 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.