I have xml with an encoding tag set to 'utf-8'. But actually it is iso-8859-1.
Programmatically, how to define this in perl and python? and how do i decode with different encoding?
In perl I tried
$xml = decode('iso-8859-1',$file)
but it does not work.
It is difficult to recognize that intelligibility is detected, since random binary data often represents valid strings in many encodings.
In Perl, the easiest way is to try to decode it as utf-8 and check for failures. (it only works like this: the desired western-language document containing utf-8 is almost always a valid iso-8859-1 document)
my $xml = eval { decode_utf8( $file, FB_CROAK ) }; if ( $@ ) { is_probably_iso-8859-1_instead }
, . , , , .
XML MIME-, Perl, , , .
XML, , , XML, , .
# assuming it on line 1: $contents =~ s/.*/<?xml version="1.0" encoding="ISO-8859-1"?>/;
, :
, .
raw_bytes UTF-8 , , UTF-8.
, , ISO-8859-1, , UTF-8 (, , ASCII, ISO-8859-1 UTF-8).
, XML, . :
<?xml version="1.0" encoding="ISO-8859-1"?>
, , ISO-8859-1, CP1252 ( Windows)?
, , XML, XML. . , 1 , , UTF-8; 2 - XML . .
Source: https://habr.com/ru/post/1785081/More articles:WPF: TreeView Item Root uses a different template, and then child nodes - templatesImport CSV file with null values in phpmyadmin - sqlHow to move from ASPX to the razor view engine in ASP.NET MVC 3? - asp.net-mvcHow to get the character encoding supported by a font programmatically? - c #Как заставить ListView правильно отображаться после нажатия на кнопку onClickListener? - androidесли не существует вставка в MySql - mysqlHidden orientation problems with orientation UIView / Layout - ioshttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1785084/convert-an-array-of-string-arrays-to-a-hash-of-string-and-float-in-ruby&usg=ALkJrhjsad64RxW1fzw3vp5j7lZt_A451wWhen implementing WizardExportResourcesPage, how can I change the selected resources? - exportThe terms of the program through the terminal - c ++All Articles