Thread String manipulation (30 answers)
Opened by Haselnuss992 at 2018-10-15 15:39

rosti
 2018-10-17 15:37
#188986 #188986
User since
2011-03-19
3470 Artikel
BenutzerIn
[Homepage]
user image
Du vermischst Byte- mit Charactersemantics. Um das mal näher zu untersuchen, Länge des Buffers gekürzt von 160 auf 2:

Code (perl): (dl )
1
2
3
4
5
6
7
8
9
10
my @u = do { 
    local $/ = \2;
    <DATA>;
};

print Dumper \@u;

use utf8;
__DATA__
€€€


Sobald Du utf8 einschaltest, kommen jede Menge Warnungen:

Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
utf8 "\xE2" does not map to Unicode at C:\Dokumente und Einstellungen\rolf\Desktop\pack.pl line 18, <DATA> chunk 1.
utf8 "\xAC" does not map to Unicode at C:\Dokumente und Einstellungen\rolf\Desktop\pack.pl line 18, <DATA> chunk 2.
utf8 "\x82" does not map to Unicode at C:\Dokumente und Einstellungen\rolf\Desktop\pack.pl line 18, <DATA> chunk 3.
utf8 "\xE2" does not map to Unicode at C:\Dokumente und Einstellungen\rolf\Desktop\pack.pl line 18, <DATA> chunk 4.
utf8 "\xAC" does not map to Unicode at C:\Dokumente und Einstellungen\rolf\Desktop\pack.pl line 18, <DATA> chunk 5.
Malformed UTF-8 character (2 bytes, need 3, after start byte 0xe2) in subroutine entry at C:/Perl/lib/Data/Dumper.pm line 207, <DATA> line 5.
Malformed UTF-8 character (unexpected continuation byte 0x82, with no preceding start byte) in subroutine entry at C:/Perl/lib/Data/Dumper.pm line 207, <DATA> line 5.
Malformed UTF-8 character (unexpected continuation byte 0xac, with no preceding start byte) in subroutine entry at C:/Perl/lib/Data/Dumper.pm line 207, <DATA> line 5.
Malformed UTF-8 character (1 byte, need 3, after start byte 0xe2) in subroutine entry at C:/Perl/lib/Data/Dumper.pm line 207, <DATA> line 5.
Malformed UTF-8 character (unexpected continuation byte 0x82, with no preceding start byte) in subroutine entry at C:/Perl/lib/Data/Dumper.pm line 207, <DATA> line 5.
Malformed UTF-8 character (unexpected continuation byte 0xac, with no preceding start byte) in subroutine entry at C:/Perl/lib/Data/Dumper.pm line 207, <DATA> line 5.
Malformed UTF-8 character (2 bytes, need 3, after start byte 0xe2) in subroutine entry at C:/Perl/lib/Data/Dumper.pm line 207, <DATA> line 5.
Malformed UTF-8 character (unexpected continuation byte 0x82, with no preceding start byte) in subroutine entry at C:/Perl/lib/Data/Dumper.pm line 207, <DATA> line 5.
Malformed UTF-8 character (unexpected continuation byte 0xac, with no preceding start byte) in subroutine entry at C:/Perl/lib/Data/Dumper.pm line 207, <DATA> line 5.


MfG

View full thread String manipulation