Results 1 to 5 of 5
  1. #1
    THUFIR is offline Member
    Join Date
    Apr 2012
    Posts
    3
    Rep Power
    0

    Default conver ANSI to plain text

    For a telnet connection to a MUD game ANSI text is returned. I've processed the text into a String, however the string keeps the ANSI encoding.

    How do you convert a String of ANSI to plain text, in order to run regex on the text data?


    thanks,

    Thufir

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,529
    Blog Entries
    7
    Rep Power
    20

    Default Re: conver ANSI to plain text

    Do you mean ASCII encoded text? (one byte per character).

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  3. #3
    THUFIR is offline Member
    Join Date
    Apr 2012
    Posts
    3
    Rep Power
    0

    Default Re: conver ANSI to plain text

    Quote Originally Posted by JosAH View Post
    Do you mean ASCII encoded text? (one byte per character).

    kind regards,

    Jos
    Yes, for a MUD client, the text, over Apache TelnetClient, is ANSI text with colors. I'm interested in converting that data to plain text. I can alread read the bytes to char, and then to string. Only, the resulting String is not plain text.

    The char data is along these lines:


    ANSI colors - Mudpedia


    which I want to turn into plain text.
    Last edited by THUFIR; 09-08-2013 at 06:10 AM.

  4. #4
    SurfMan's Avatar
    SurfMan is online now Godlike
    Join Date
    Nov 2012
    Location
    The Netherlands
    Posts
    947
    Rep Power
    2

    Default Re: conver ANSI to plain text

    I assume you already found this snippet on SO? It does a bit more than you request here, but the parsing of escape sequences is in there.
    Last edited by SurfMan; 09-08-2013 at 09:19 AM. Reason: Forgot link to the actual snippet (doh...)

  5. #5
    THUFIR is offline Member
    Join Date
    Apr 2012
    Posts
    3
    Rep Power
    0

    Default Re: conver ANSI to plain text

    Actually, no I hadn't seen that! I did find a python function, though:

    sys.stdout.isatty
    python - Printing to STDOUT and log file while removing ANSI color codes - Stack Overflow

    so something like that is what I was looking for, but, obviously, for Java. Hmm, maybe I'll have another look at Apache I/O, actually...

    Further searches show Jenkin's uses ANSI, too:

    https://wiki.jenkins-ci.org/display/...siColor+Plugin
    Last edited by THUFIR; 09-08-2013 at 12:12 PM.

Similar Threads

  1. Plain text from XML
    By acio23 in forum XML
    Replies: 3
    Last Post: 05-14-2012, 02:27 PM
  2. Scanning a Plain text file
    By aw249 in forum New To Java
    Replies: 3
    Last Post: 02-03-2012, 05:16 PM
  3. Replies: 3
    Last Post: 06-08-2010, 08:10 PM
  4. Indentation - plain text
    By barney75 in forum New To Java
    Replies: 1
    Last Post: 03-23-2009, 05:54 PM
  5. convert html to plain text
    By vissu007 in forum New To Java
    Replies: 3
    Last Post: 07-07-2007, 02:39 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •