Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Lynx UTF-8 support

Tags:

utf-8

lynx

I am using Lynx on OS X 10.11. However, it does not print UTF-8 for non-ASCII characters, but rather either an ASCII representation of them, or the ef bf bd "replacement" character (?).

I have been studying this guide for help.

The output from the locale command:

locale
LANG="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_CTYPE="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_ALL=

When I run Lynx with

lynx http://www.cl.cam.ac.uk/~mgk25/ucs/examples/UTF-8-demo.txt

here is what the display appears like:

Lynx displays UTF-8 test page incorrectly

According to the posts in the article, Lynx should print UTF-8 properly.

lynx -dump ... prints the same.

(running export LC_ALL="en_US.UTF-8" doesn't help either.)

What is strange, is that if I run with the -mime_header argument, eg:

lynx -mime_header http://www.cl.cam.ac.uk/~mgk25/ucs/examples/UTF-8-demo.txt

It prints the characters properly. (Albeit, as a dump rather than opening in a browser environment):

Lynx displays UTF-8 test page correctly

EDIT:

Forgot to mention,

-assume_charset=utf8 and -assume_unrec_charset=utf8

don't help either.

EDIT:

Well I am able to get the output I want by hard-setting CHARACTER_SET in lynx.cfg. Though this seems like a bit of a workaround, as in the documentation it states:

# ...  The 'o'ptions menu setting will be stored in the user's RC
# file whenever those settings are saved, and thereafter will be used as the
# default.  ...

However, the setting only persists for the session it is set in. That won't work for me as I am primarily using lynx -dump in a script. But as I pretty much am only UTF-8, I guess I can live with the hard setting for now.

like image 497
KevinHJ Avatar asked Jul 26 '18 22:07

KevinHJ


1 Answers

I do think you should use

lynx -dump --display_charset=utf-8

rather than hard-setting the config file

so

lynx --display_charset=utf-8 http://www.cl.cam.ac.uk/~mgk25/ucs/examples/UTF-8-demo.txt

alternatively

check https://www.brow.sh/

like image 101
xiaoou wang Avatar answered Oct 21 '22 21:10

xiaoou wang