LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   console text encoding (https://www.linuxquestions.org/questions/linux-newbie-8/console-text-encoding-608888/)

rajmohannambiar 12-24-2007 08:28 AM

console text encoding
 
I am using Upsilon for linux to monitor a UPS. The status is output to the console in a tabular format (voltage , current etc) using control codes. But, in the output I am getting, all text appears continuous, and instead of newline character, I get 79H. For example, it actually wanted to display '230v' under 'voltage', but what gets displayed is voltage79H230V etc. similarly, lot of other characters appear with some numbers. I guess this is because of wrong character sets or encoding for the console. How to set things right? I can see in the software the correct screenshots, but they appear different in my Suse linux.

theNbomr 12-24-2007 09:27 AM

You are seeing the escape codes used to format the text on the terminal. Assuming that you want to extract the text only, for logging or some other purpose, you will need to find out what kind of terminal is being used, and then you can probably find a reference for the escape character 'language' used by that terminal. From that, you should be able to write a parser in some language such as perl. What are you presently using to capture the output?
--- rod.

rajmohannambiar 12-24-2007 10:30 AM

Thanks Rod. But then, should I be seeing the escape codes at all, inside the console? Like, if I open word file in word, then I wouldn't see the control codes, but I will be able to see them if I open it in a plain editor. In the same sense, I should see formatted output. Like instead of newline character, I should actually see a newline. Shouldn't I? I am using bash in Suse. Upsilon manual also shows screenshots with formatted text. ie: Text that looks as if it is formatted as a table, sans the lines. Is it because I have not set the encoding properly?

rajmohannambiar 12-24-2007 10:38 AM

Do I need to tweak bashrc to format the encoding of escape characters?

theNbomr 12-24-2007 12:46 PM

Yes, the concept is similar to the formatting codes embedded in a word processor document. If you look at the file with a different tool, the way it displays the formatting codes will be undefined, since they are intended only for the specific application that created them. Similarly, a console with a terminal emulator will trap the escape codes, and use them to format the text display. Capturing the raw byte stream intended to be parsed by the terminal emulator should result in capturing ALL of the bytes, including the embedded escape sequences. You seem to be expecting the captured byte stream to be correctly displayed on a terminal, when 'replayed'. This is a reasonable expectation, if the terminal matches the type expected by the original application that generated it, and if the tools used to capture and replay the byte stream have not modified it in any way. What tools and methods are you using to perform these actions?
--- rod.

theNbomr 12-24-2007 01:06 PM

Okay, now I've re-read your original post, and and I think I've misinterpreted your question. If I now understand correctly, you are seeing 'garbage' characters from your application, rather than the nice tabular formatting you expect. The likely cause of this is a mismatch of the terminal emulator that the application expects (should be documented), and the terminal actually being emulated. By default, most Linux consoles will behave much like a DEC VT-100 terminal. The 'TERM' environment variable should reflect this, and ideally, the application using the terminal should use this information to send the correct escape sequences for the terminal in use. What is the value of your present '$TERM' variable (use the actual console window used by your application)?
Code:

echo $TERM
I am not an expert in configuring linux terminal emulation, and it is a somewhat complex issue with several interracting parts. It would be good to clearly define the problem before proposing any solution.
--- rod.

rajmohannambiar 12-25-2007 02:28 AM

Thank you Sir. I will find out the detail and come back to you. The machine is not accessible till 27nth. Thanks again for your kind response.

rajmohannambiar 01-13-2010 02:32 AM

Thank you
 
Got it solved by by configuring the console, but in linux distros, it isn't giving good results. Not sure why. Anyway, I wrote an application from scratch, and used webbrowser to display the results, instead of console.

Thanks a lot !


All times are GMT -5. The time now is 07:06 AM.