Autor Beitrag
DevInet
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 43

Win XP, Win 7 Prof., Linux Mandriva
C#(VS 2010), Java, php
BeitragVerfasst: Di 19.10.10 09:30 
Hallo zusammen.

Ich kämpfe moment mit dem Streamreader in meinem Programm.
Folgendes ist der aktuelle Status.
Ich habe in einer Datei Personendaten stehen, inklusive Telefonnummern in folgender Form: +49 (vorwahl) rufnummer
Beim einlesen über den Streamreader wird aber nur folgender Teil eingelesen: (vorwahl) rufnummer
Nun frage ich mich wo die +49 abgeblieben ist.

Hier noch ein Code-Beispiel:
ausblenden C#-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
StreamReader tempread1 = new StreamReader(@"C:\Peronendaten.txt", System.Text.Encoding.UTF7, true);
                {
                    //Löschen des aktuellen Inhalts aus der ListBox
                    fBox.Items.Clear();
                    string line;
                    //Überprüfung auf Leerzeilen
                    while ((line = tempread1.ReadLine()) != null)
                    {
                        //Ausgabe der Liste in der ListBox
                        fBox.Items.Add(line);
                    }
                }
                tempread1.Close();


Ich hoffe einer von euch kann mir da weiterhelfen.

Danke schonmal im vorraus.

Mfg DevInet
Trashkid2000
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 561
Erhaltene Danke: 137



BeitragVerfasst: Di 19.10.10 09:55 
Hi,

habe mal folgendes in der Wikipedia über UTF7 gefunden:
ausblenden Quelltext
1:
"1 + 1 = 2" is encoded as "1 +- 1 = 2"					
Soll heißen, wenn Deine Textdatei wirklich UTF7 wäre, dann müsste es so codiert sein:
ausblenden Quelltext
1:
+-49 (vorwahl) rufnummer					
Also, änder einfach mal das Encoding des Streamreaders auf UTF8, und damm klappt das schon.

Weiß auch nicht, wie Ihr immer auf so abgefahrende Codierungsangaben kommt!

LG, Marko
DevInet Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 43

Win XP, Win 7 Prof., Linux Mandriva
C#(VS 2010), Java, php
BeitragVerfasst: Di 19.10.10 10:00 
Habs getestet.
Die Telefonnummer geht jetzt, dafür hat er jetzt die Probleme mit ü,ä.ö.

Beispiel: Mit freundlichen Gr��en


Mfg DevInet
Trashkid2000
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 561
Erhaltene Danke: 137



BeitragVerfasst: Di 19.10.10 10:11 
Dann ist Deine Datei unter einen anderen Unicode-Kodierung gespeichert worden. Gibt ja genug davon.
Oder Du musst sie mal mit einem Texteditor konvertieren.

Für diesen Beitrag haben gedankt: DevInet
DevInet Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 43

Win XP, Win 7 Prof., Linux Mandriva
C#(VS 2010), Java, php
BeitragVerfasst: Di 19.10.10 10:18 
Hab glaub ich das Problem gefunden.
Sind alle in ANSI codiert.
DevInet Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 43

Win XP, Win 7 Prof., Linux Mandriva
C#(VS 2010), Java, php
BeitragVerfasst: Di 19.10.10 10:25 
Nach der Konvertierung in UTF8 gehts.
ANSI is Schuld.
Danke für die Hilfe.