Thread Perl Regular Expression - merkwürdiges Verhalten (16 answers)
Opened by GoodFella at 2007-03-24 00:04

GoodFella
 2007-03-24 21:16
#75309 #75309
User since
2007-01-09
192 Artikel
BenutzerIn
[default_avatar]
[quote=kristian,24.03.2007, 19:31]Hallo

Quote
Warum ist das überhaupt so, ich hatte jahrelang niemals Probleme damit.
Weiss jemand eine Lösung?


Ich kriegs nicht mehr zusammen.
Der Grund ist Unicode bzw. die Umstellung auf und Unterstützung von Unicode.
Irgendwo in der Doku eines der Module, frag mich bitte nicht, das ist so lange her das ichs gelesen habe, steht - da bin ich sicher - das es geschehen kanns das zwei Strings die gleich aussehen in einer Regex nicht gleich sind.
Gesetzte HiBits oder was auch immer, ich hoffe einer der echten Profis hier erinnert das besser.

Gruss
Kristian[/quote]
Dann sollte es aber einen switch geben, der dieses Verhalten abstellen kann.. hoffe ich :(

Hab mir mal perdoc utf8 angeschaut.. zuerst no utf8; getestet -> kein Effekt. Dann mal das probiert:

Code (perl): (dl )
&debug('is_utf8(male_cmp) = '.utf8::is_utf8($male_cmp).', is_utf8(sex_cmp) = '.utf8::is_utf8($sex_cmp));


output:

Quote
is_utf8(male_cmp) = 1, is_utf8(sex_cmp) =


Am liebsten wär mir eine Zeile am Anfang des Scriptes, die bewirkt, dass jegliche verwendeten Variableninhalte, wenn nicht schon so vorhanden, utf8::down-ge-grade-ded werden :)

[EDIT]
use utf8 geht bei mir gar nicht, Fehlermeldung:

Quote
---------- Perl ----------
Malformed UTF-8 character (unexpected continuation byte 0xa7, with no preceding start byte) at mmc.pl line 709, <DATA> line 164.
Malformed UTF-8 character (unexpected non-continuation byte 0xe4, immediately after start byte 0xfc) at mmc.pl line 709, <DATA> line 164.
Malformed UTF-8 character (unexpected non-continuation byte 0xf6, immediately after start byte 0xe4) at mmc.pl line 709, <DATA> line 164.
Malformed UTF-8 character (unexpected non-continuation byte 0x5c, immediately after start byte 0xf6) at mmc.pl line 709, <DATA> line 164.
Malformed UTF-8 character (unexpected continuation byte 0xb5, with no preceding start byte) at mmc.pl line 709, <DATA> line 164.
Malformed UTF-8 character (unexpected continuation byte 0x80, with no preceding start byte) at mmc.pl line 709, <DATA> line 164.
Malformed UTF-8 character (unexpected continuation byte 0xb4, with no preceding start byte) at mmc.pl line 709, <DATA> line 164.
Malformed UTF-8 character (unexpected non-continuation byte 0x20, immediately after start byte 0xdf) at mmc.pl line 709, <DATA> line 164.
Malformed UTF-8 character (unexpected continuation byte 0xa7, with no preceding start byte) at mmc.pl line 2809, <DATA> line 164.
Malformed UTF-8 character (unexpected non-continuation byte 0xe4, immediately after start byte 0xfc) at mmc.pl line 2809, <DATA> line 164.
Malformed UTF-8 character (unexpected non-continuation byte 0xf6, immediately after start byte 0xe4) at mmc.pl line 2809, <DATA> line 164.
Malformed UTF-8 character (unexpected non-continuation byte 0xdc, immediately after start byte 0xf6) at mmc.pl line 2809, <DATA> line 164.
Malformed UTF-8 character (unexpected non-continuation byte 0xc4, immediately after start byte 0xdc) at mmc.pl line 2809, <DATA> line 164.
Malformed UTF-8 character (unexpected non-continuation byte 0xd6, immediately after start byte 0xc4) at mmc.pl line 2809, <DATA> line 164.
Malformed UTF-8 character (unexpected non-continuation byte 0x5c, immediately after start byte 0xd6) at mmc.pl line 2809, <DATA> line 164.
Malformed UTF-8 character (unexpected continuation byte 0xb5, with no preceding start byte) at mmc.pl line 2809, <DATA> line 164.
Malformed UTF-8 character (unexpected continuation byte 0x80, with no preceding start byte) at mmc.pl line 2809, <DATA> line 164.
Malformed UTF-8 character (unexpected continuation byte 0xb4, with no preceding start byte) at mmc.pl line 2809, <DATA> line 164.
Malformed UTF-8 character (unexpected non-continuation byte 0x20, immediately after start byte 0xdf) at mmc.pl line 2809, <DATA> line 164.
@ 535 not utf8
SV = PV(0x3c3e880) at 0x2d14630
 REFCNT = 1
 FLAGS = (POK,pPOK,UTF8)
 PV = 0x3c56ffc "Hinzuf\374gen"\0Could not open Y:\Pete\Perl\Projekte\mmComplete\error_log.txt! at mmc.pl line 504, <DATA> line 164.
[UTF8 "Hinzuf\x{2796e005}"]
 CUR = 10
 LEN = 12
SV = PVMG(0x3c5733c) at 0x2d14630
 REFCNT = 1
 FLAGS = (SMG,POK,pPOK,UTF8)
 IV = 0
 NV = 0
 PV = 0x3c56ffc "Hinzuf\374gen"\0 [UTF8 "Hinzuf\x{2796e005}"]
 CUR = 10
 LEN = 12
 MAGIC = 0x3c58f24
   MG_VIRTUAL = &PL_vtbl_utf8
   MG_TYPE = PERL_MAGIC_utf8(w)
   MG_LEN = 6

Output completed (3 sec consumed) - Normal Termination


In den entsprechenden Zeilen steht ein Whitelist-Regex:

Code (perl): (dl )
            $data =~ s/[^A-Za-z0-9!§$%&\/()=?{[\]}\\+#*'üäöÜÄÖ\-.,;:_<>|µ¤~\n\t\^&acute;ß ]/ /sg;


Weiss leider nicht, was ich weiter tun kann..

[EDIT2]:
Nächster Test: use locale auskommentiert. ->Es funktioniert alles wie erwartet! Leider kann ich dann keine Dateien mit Umlauten öffnen.. also auch keine Lösung...
Bin am verzweifeln.
Perl fand ich immer so geil, weil es dir den ganzen unnötigen Müll abnimmt und du nur das wesentliche programmieren musst. Momentan geht Perl da völlig falsche Wege :/\n\n

<!--EDIT|GoodFella|1174765539-->

View full thread Perl Regular Expression - merkwürdiges Verhalten