Comments (6)
You means something this?
#!/usr/bin/perl
use warnings;
use strict;
use HTML5::DOM;
use utf8;
use Encode;
my $parser = HTML5::DOM->new;
my $s = HTML5::DOM->new->parse('<b>пыщь пыщь</b>')->at('b')->text;
Encode::_utf8_on($s);
print $s." ололо\n";
Yes, all strings in utf-8. But default behavior - work with bytes.
I will try implement optional utf8 mode.
Something like this:
utf8 => "auto": if passed source with SvUTF8 == 1, then switch to utf8 mode [default]
utf8 => 1: switch to utf8 mode
uft8 => 0: work with bytes
from perl-html5-dom.
Yes, exactly.
Usually ->text
extracted for comparison or concatenation and it is more handy, if it will be encoded to utf8, because this is text string, not a bytes array.
You can use sv_utf8_decode(sv)
- to decode or SvUTF8_on(sv)
to just set utf8 flag (will be faster) in your XS code.
from perl-html5-dom.
Implemented in 1.14 version.
Doc:
https://github.com/Azq2/perl-html5-dom#work-with-utf8
https://github.com/Azq2/perl-html5-dom#parser-options
https://github.com/Azq2/perl-html5-dom#utf8
from perl-html5-dom.
Seems, that it works.
One more issue:
according to the spec. I can set encoding manually in parser->new:
encoding
Encoding of input HTML, if auto - library can tree to automaticaly determine encoding. (default "auto")
Allowed both encoding name or id.
but if I specify encoding as string
my $parser = HTML5::DOM->new({ encoding => 'WINDOWS-1251' });
it produces error:
HTML5::DOM::_parseAsync(): invalid encoding value at /usr/perlbrew/perls/perl-5.28.1/lib/site_perl/5.28.1/x86_64-linux-ld/HTML5/DOM.pm line 321.
from perl-html5-dom.
Fixed in 1.15. Regression test added.
from perl-html5-dom.
I think problem resolved. Please, open if not.
from perl-html5-dom.
Related Issues (9)
- Packaging issue — 1.01 includes 1.00 as a tar file HOT 1
- Problems when html's charset is windows-1253
- How async mode works? HOT 6
- Why largest threads number runs slower? HOT 13
- Strange encoding: utf-8 instead windows-1251 HOT 6
- Bad examples for outerHTML and innerHTML HOT 2
- Calling replace method with a fragment stops responding
- HTML5-DOM-1.23: Warning: the following files are missing in your kit HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from perl-html5-dom.