Schrift
Wiki:Tipp zum Debugging: use Data::Dumper; local $Data::Dumper::Useqq = 1; print Dumper \@var;
[thread]7145[/thread]

Charsetproblem: utf8 zu HTML-Codierung (Seite 2)

Leser: 5


<< |< 1 2 3 >| >> 29 Einträge, 3 Seiten
GwenDragon
 2005-07-21 14:10
#56530 #56530
User since
2005-01-17
14837 Artikel
Admin1
[Homepage]
user image
Code: (dl )
1
2
3
4
5
6
Ich nehme an, der String soll wohl so sein:
#!/usr/bin/perl
use Encode ();
my $data='fÃ&¼r'; # ist für in UTF8
Encode::from_to($data, "utf8", "iso-8859-1");
print $data;


Arg das forum macht aus dem 1/4 (ein Zeichen!) ein &¼

Zudem Dekodiert Encode nur von->nach Zeichensatz.
Es erzeugt keine HTML-Entities!\n\n

<!--EDIT|GwenDragon|1121940959-->
GreenRover
 2005-07-21 14:29
#56531 #56531
User since
2005-07-20
11 Artikel
BenutzerIn
[default_avatar]
und wie mache ich da jetzt HTML entities draus???

ja, das macht der Browser:

http://web100.movetec-server.ch/cgi-bin/test.pl

das erste ist meine variabelle und das 2 die umwandlung davon.\n\n

<!--EDIT|GreenRover|1121941941-->
GwenDragon
 2005-07-21 14:53
#56532 #56532
User since
2005-01-17
14837 Artikel
Admin1
[Homepage]
user image
Quote
perldoc HTML::Entities

NAME
   HTML::Entities - Encode or decode strings with HTML entities

SYNOPSIS
    use HTML::Entities;

    $a = "V&aring;re norske tegn b&oslash;r &#230res";
    decode_entities($a);
    encode_entities($a, "\200-\377");

   For example, this:

    $input = "vis-Ó-vis BeyoncÚ's na&´ve\npapier-mÔchÚ rÚsumÚ";
    print encode_entities($in), "\n"

   Prints this out:

    vis-&agrave;-vis Beyonc&eacute;'s na&iuml;ve
    papier-m&acirc;ch&eacute; r&eacute;sum&eacute;

DESCRIPTION
   This module deals with encoding and decoding of strings with HTML
   character entities. The module provides the following functions:

   decode_entities( $string )
       This routine replaces HTML entities found in the $string with the
       corresponding ISO-8859-1 character, and if possible (under perl 5.8
       or later) will replace to Unicode characters. Unrecognized entities
       are left alone.

       This routine is exported by default.

   encode_entities( $string )
   encode_entities( $string, $unsafe_chars )
       This routine replaces unsafe characters in $string with their entity
       representation. A second argument can be given to specify which
       characters to consider unsafe (i.e., which to escape). The default
       set of characters to encode are control chars, high-bit chars, and
       the "<", "&", ">", and """ characters. But this, for example, would
       encode *just* the "<", "&", ">", and """ characters:

         $escaped = encode_entities($input, '<>&"');

       This routine is exported by default.

   encode_entities_numeric( $string )
   encode_entities_numeric( $string, $unsafe_chars )
       This routine works just like encode_entities, except that the
       replacement entities are always "&#x*hexnum*;" and never
       "&*entname*;". For example, "escape_entities("r\xF4le")" returns
       "r&ocirc;le", but "escape_entities_numeric("r\xF4le")" returns
       "r&#xF4;le".

       This routine is *not* exported by default. But you can always export
       it with "use HTML::Entities qw(encode_entities_numeric);" or even
       "use HTML::Entities qw(:DEFAULT encode_entities_numeric);"

   All these routines modify the string passed as the first argument, if
   called in a void context. In scalar and array contexts, the encoded or
   decoded string is returned (without changing the input string).

   If you prefer not to import these routines into your namespace, you can
   call them as:

     use HTML::Entities ();
     $decoded = HTML::Entities::decode($a);
     $encoded = HTML::Entities::encode($a);
     $encoded = HTML::Entities::encode_numeric($a);

   The module can also export the %char2entity and the %entity2char hashes,
   which contain the mapping from all characters to the corresponding
   entities (and vice versa, respectively).

COPYRIGHT
   Copyright 1995-2003 Gisle Aas. All rights reserved.

   This library is free software; you can redistribute it and/or modify it
   under the same terms as Perl itself.
GreenRover
 2005-07-21 15:33
#56533 #56533
User since
2005-07-20
11 Artikel
BenutzerIn
[default_avatar]
Danke für den Tip, aber ich bekomem es immern och ncith hin!!!!


wie bekomme ich nun aus meinem ursprüunglichen: fÃ&¼r ein f&uuml;r ??\n\n

<!--EDIT|GreenRover|1121945619-->
Ronnie
 2005-07-21 15:43
#56534 #56534
User since
2003-08-14
2022 Artikel
BenutzerIn
[default_avatar]
Code: (dl )
1
2
3
4
5
6
7
8
9
#!/usr/bin/perl

use strict;
use warnings;

use HTML::Entities;

my $in = "Übelkeit durch Ärgerniß";
print encode_entities($in), "\n";
GreenRover
 2005-07-21 16:07
#56535 #56535
User since
2005-07-20
11 Artikel
BenutzerIn
[default_avatar]
soweit bin ich doch naoch garnicht !!!!! ich habe kein ü oder so sondern das ganze ist utf8 kodiert und ich habe kein chimmer wie ich aus meinen komischen Zeichen ein ü bekomme!!!!!!!!!\n\n

<!--EDIT|GreenRover|1121947683-->
GwenDragon
 2005-07-21 16:12
#56536 #56536
User since
2005-01-17
14837 Artikel
Admin1
[Homepage]
user image
#!/usr/bin/perl
use Encode ();
use HTML::Entites ();

my $data='fÃ&¼r'; # ist für in UTF8
Encode::from_to($data, "utf8", "iso-8859-1");

print HTML::Entites::encode_entities($data)
GreenRover
 2005-07-21 16:26
#56537 #56537
User since
2005-07-20
11 Artikel
BenutzerIn
[default_avatar]
die ausgabe davon ist: f?&amp;¼r


das funktionirt nicht!!! da das utf kein ü ist sonder schon ein HTML entetie in UTF laut: esskar\n\n

<!--EDIT|GreenRover|1121948858-->
pKai
 2005-07-21 17:01
#56538 #56538
User since
2005-02-18
357 Artikel
BenutzerIn
[default_avatar]
das funktioniert schon (abgesehen von Typos und nicht existierenden sub-Namen).
Schritt für Schritt:
Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#!/usr/bin/perl
use Encode ();
use HTML::Entities ();

local $\ = $/;

my $data='für'; # ist 'ü', wie man sieht
print $data;
Encode::from_to($data, "iso-8859-1", "utf8"); # 'ü' unabhängig von jeder Verhunzung der Anzeige des Literals im Board!
print $data;
Encode::from_to($data, "utf8", "iso-8859-1");
print $data;
HTML::Entities::encode($data);
print $data;

http://wiki.perl-community.de/pub/User/KaiSengpiel...\n\n

<!--EDIT|pKai|1121951319-->
I sense a soul in search of answers.
GreenRover
 2005-07-21 17:06
#56539 #56539
User since
2005-07-20
11 Artikel
BenutzerIn
[default_avatar]
NEIN!!!

das fÃ&¼r wird nicht vom board verhuntst!!! Das sieht wirklich so aus bei mir. Ich bekomem die Variabelle so übergeben und muss sie nun HTML encodieren.

Und das Problem habe ich 2Post weiter oben schon beschieben, das daß Ã&¼ kein ü ist sondern eine utf8 encodierte HTML entetie. Aus der eich einfach keien latin1 encodiete HTML entetie bekomme.\n\n

<!--EDIT|GreenRover|1121951268-->
<< |< 1 2 3 >| >> 29 Einträge, 3 Seiten



View all threads created 2005-07-20 23:46.