How can we post ASCII art on Facebook wall?

In my application, I have a requirement to publish ASCII art from my iPhone application on a facebook post. But the problem I am facing is that the facebook font (Lucida Console) is changing the formatting of my ASCII art. I made my ASCII art at Courier New.

What can be done?

Is there a way to post my ASCII art to facebook without reformatting it all?

Please help and suggest.

thank

+3
source share
2 answers

- . , . ASCII- - lentgh .

facebook css:

font-family: 'lucida grande', tahoma, verdana, arial, sans-serif;

Lucida Grande . , m. .


facebook.

  • , .


   ♥♥'''''''''''''''♥♥
   ♥♥'''''''''''''''♥♥


♥♥ '' '' '' '' '' '' '' '♥♥

+4

Python script, .

#!/usr/bin/python
'''
fbformat -- format ASCII for Facebook
'''
import sys, os
PRINTABLE = [' '] + map(chr, range(ord('!'), ord('~') + 1))
FB_ABLE = [u'\u3000'] + map(unichr, range(0xff01, 0xff5f))
TO_FB = dict(zip(PRINTABLE, FB_ABLE))
FROM_FB = dict(zip(FB_ABLE, PRINTABLE))
COMMAND = os.path.splitext(os.path.basename(sys.argv[0]))[0]
TEXT = sys.stdin.read().decode('utf8')
TO = ''.join([TO_FB.get(C, C) for C in TEXT])
FROM = ''.join([FROM_FB.get(C, C) for C in TEXT])
sys.stdout.write([TO, FROM][COMMAND == 'fbunformat'].encode('utf8'))

~/home/bin/fbformat ~/home/bin/fbunformat, , ~/home/bin PATH.

test.txt :

YES!
\o/
 |
/ \

jcomeau@aspire:~/rentacoder/gdavis$ fbformat < /tmp/test.txt
YES!
\o/
 |
/ \
jcomeau@aspire:~/rentacoder/gdavis$ fbformat < /tmp/test.txt | fbunformat
YES!
\o/
 |
/ \

: http://www.cs.tut.fi/~jkorpela/chars/spaces.html https://en.wikipedia.org/wiki/Halfwidth_and_fullwidth_forms

0

Source: https://habr.com/ru/post/1778237/


All Articles