Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6758267
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:45:47+00:00 2026-05-26T13:45:47+00:00

I’d appreciate suggestions on how I can convert ASCII control characters, which are supplied

  • 0

I’d appreciate suggestions on how I can convert ASCII control characters, which are supplied via an HTML text box, to their hexadecimal or binary representations.

Currently, my web app, takes the ASCII control character string and converts the values, for example, if ^C is entered the value 5e43 is returned which represents “^” and “6”, not control-c which is represented as 02 in hex.

The idea I had was to run a regex against the input to check for control characters with something like: ^[\w]{1} and then return values from a predefined table that matches the regex.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T13:45:48+00:00Added an answer on May 26, 2026 at 1:45 pm

    You can directly read from in with (. *in* read) though how the characters get to you is going to be dependent on a lot of things, most specifically the case that the browser is likely to encode them for http transport before you even get started.

    I maintain a secure terminal proxy that has to handle all combinations of control characters so I thought I would pass on a few notes:

    • they are not one character long. you need up to six characters to represent them. try hitting Esc–Ctrl–alt–left-arrow.
    • esc implies Alt but alt does not imply esc. if the first character is an esc then the next character is the meta/alt of its character value. so if you see esc–b this is Alt–b
    • some keys (page up for example) send the esc automatically.
    • esc–esc is it’s own thing (which I can’t say I fully understand).

    The best way is to write a small program that reads from the keyboard one character at a time and then start mashing the keyboard and see what you can come up with.

    Here I will read a character from in twice and hit home the first time and end the second

    clojure.core=> (. *in* read)
    10
    clojure.core=> (. *in* read)
    10
    

    So clearly one character is not enough to distinguish these two keys, how about two characters?

    This next example won’t run in the repl because the repl tries to “handle” control character for you, so you will have to make a new project lein new esc add this code then lein uberjar and java -jar esc-1.0.0-SNAPSHOT-standalone.jar

    (ns esc.core
      (:gen-class))
    
    (defn -main []
      (dorun (repeatedly #(println (. *in* read)))))
    

    Running it and hitting these two keys produces this:

    ^[OF
    27
    79
    70
    10      <-- this is the newline
    ^[OH
    27      <-- esc start marker look for this
    79
    72
    10      <-- this is the newline
    

    Here is esc–end

    ^[^[OF
    27
    27
    79
    70
    10
    

    And the ctrl character grand prize winner thus far esc–right-arrow

    ^[[1;5C
    27
    91
    49
    59
    53
    67
    10
    

    taking the prize at six bytes.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a text area in my form which accepts all possible characters from
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.