F
F
Felix Banan @Felix2020-03-30 19:56:13
PHP
Felix Banan @Felix, 2020-03-30 19:56:13

Phantomjs does not want to work with Cyrillic, how to fix it?

The problem is that PhantomJS refuses to recognize Cyrillic.
screen.js file

var page = require('webpage').create();
page.viewportSize = { width: 800, height: 600 };
page.zoomfactor = 1;
page.open('http://seelnk.ru/graphgen/graphgen.php?label=ТЕСТ&data=1,2,3,4,5&labels="1", "2", "3", "4", "5"', {
    charset: 'utf-8', // или utf8
}, function(status) {

    if (status !== 'success') {
        console.log('Unable to load the address!');
        phantom.exit();
    } else {
        window.setTimeout(function () {
            console.log('Load the address!');
            page.dpi = 300;
            page.render('Newpdf.png',{format: 'png', quality: '100'});
            phantom.exit();
        }, 1000); // Change timeout as required to allow sufficient time 
    }

  //phantom.exit();
});


shot.php file
<?php
     $exec = 'phantomjs  screen.js'; 
     $escaped_command = escapeshellcmd($exec);
     exec($escaped_command);
?>


Gives out question marks on top instead of the inscription TEST:
5e82240446ee9163715915.png

How to fix it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
nokimaro, 2020-03-30
Banan

Try to urlencode the label value from the request

page.open('http://seelnk.ru/graphgen/graphgen.php?label=%D0%A2%D0%95%D0%A1%D0%A2&data=

TEST = %D0%A2%D0%95%D0%A1%D0%A2 in UTF-8

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question