CentOS 5 :: Convert Between "ASCII English Text" And "ASCII Text"?
Aug 3, 2011
This is weird, and I never noticed before, but now I have an application that is borking on weird things like when /etc/hosts is of one file format or another, and I don't even know the difference between the two (google doesn't tell much either). on CentOS 5.5/5.6 x86_64: a which on the following is an interesting tell:
vi = /bin/vi
vim = /usr/bin/vim
both are actually vim version 7.0.237 but sum differently, and although they are both actually separate executables in the stock installs of CentOS I've been building, on most distros, and older versions of CentOS it seems, vi is usually just a symlink to vim - but again, not in these fresh installs it seems. When I create a file with the 'vi' above, it defaults (usually) to "ASCII text" (but not always) When I create a file with the 'vim' above, it defaults to "ASCII English text" (and causes a particular application I'm working with to bork and barf). It seems the OS is installed by default yielding both file types too, as evidenced by the following:
To start off I would like to acknowledge that I am not a very good C programmer and pretty much everything I know has been self taught through mostly trial and error. So forgive me if there is an obvious answer to my question, or if I don't immediately grasp the concepts involved in the possible solution.
Basically, I'm writing an application which will be creating log file entries rather rapidly (potentially hundreds per minute), and I would like each new line to appear at the top of the log file, rather than the end. Opening a text file in append mode is easy enough, but I can't seem to find any obvious way to do the opposite.
I have been looking online and it seems that there exists no standard way to do this, and I have only been able to find a few mentions of how somebody might achieve it. The most common method seems to be using two files and copying the data back and forth between them. This seems like it would be insanely I/O intensive with the number of lines I'm likely to be generating. If this is the best method to use, I will give it a shot; though I am not 100% clear on how to implement it, I am also open to any other ideas as to how to accomplish this, and I don't have to worry about portability since the program already uses Linux-only libraries. So calling out to sed or something is not necessarily out of the question (though I imagine performance would also be an issue there).
To encrypt the text, we take the word "python" and make it at least the same size as "welcome home" by repeating it as follows:
w e l c o m e h o m e p y t h o n p y t h o n Then, we convert each letter into its numerical ASCII value as follows: w e l c o m e h o m e = 119 101 108 099 111 109 101 032 104 111 109 101
[Code].....
And, finally, we convert the numbers back into their corresponding ASCII character:
I have a file of 2GB size in hex form. This is a log file from the server which I converted to hex as the file got corrupted.Can anyone tell how to convert this hex file to ASCII?
i tried installing the GUI mode but it didnt happen. My system restarted in between the installation. So i installed the text mode. Now how to switch over to the GUI mode?
I would like to write a text user interface (TUI) to adjust some text config files etc. Is there a tool or application for creating TUIs like this. I�m talking about those types of config tools which you see executed at first boot.
I need to be able to switch between English and Japanese text when typing on my computer but I have no idea how to. I figured it out on both Windows and Mac but Ubuntu is giving me some trouble. I figure IBus is where I'm supposed to be going but even though I selected Japanese, it just isn't working.
How can I use extended ascii characters, like ALT + 2 + 0 + 0 for instance? I'm using some of those characters for my passwords for online accounts made under MS Windows and it seams I'm unable to use them in Slackware 13. For instance: if I type ALT+2+0+0 in Pidgin there is no character displayed and if I type in the Terminal the same thing, it will replace my shell prompter (sasser@HOSTA:~$) with (arg: 200): sasser@HOSTA:~$ (arg: 200)
How can I filter ASCII quotes( ' ) and double quotes ( " ) so that I can replace them with the UTF-8 equivalent?If I copy text from a Word Document(ASCII), and upload it to a web page with PHP. The Database(UTF-8) will replace these racters with incorrect character(s).I need some function that will replace these characters but I don't know how to differentiate the ASCII quotes and the UTF-8 Quotes without (somehow) converting the string to hex, then preg_replace'ing the hex code for the symbol.
Well, I have a web application in Linux server. All my Java codes are there. FYI, whenever user entered non-ASCII characters(e.g. ∞,�,�) in a text field in my web application, and I check the log of my Java code in Linux server, it returns weird characters.
Suppose user entered ∞ in the text field. I should get ∞ in my log too. However, I got weird characters in return.
i want to print all ASCII characters kind of like a table, but i really don't have an idea of how to do it, i don't know if there is a built-in method or something to accomplish this, if not
entry->d_name is a 256 byte character array returned by readdir(), I would expect this line of code to convert that character array from ascii to a QString, but I get a seg fault and I'm not entirely sure why..
What do i have to make to be able to watch a movie in a TTY...? there is this library called AAlib, and there is a slackbuild for it, form osuosl [URL], but besides of this I do not know how it is done...
I'm trying to get mplayer to play videos in ASCII, but I get an error... I don't know why. It works fine on my desktop, but my laptop is outputting an error...
This is the command:
Code: mplayer -vo aa video.flv
This is the error I get:
Quote:
MPlayer SVN-r29800-4.4.2 (C) 2000-2009 MPlayer Team mplayer: could not connect to socket mplayer: No such file or directory Failed to open LIRC support. You will not be able to use your remote control.
I am working on a project where I am dialing out of a modem!! Old stuff, ya, but the modem allows my device send info from remote sites from my datibase through a phone line so that this IT departments dont have to worry my device being a security issue on their networks.
Any way, the modem I'm using isn't incredibly well designed, and when a certain ascii char is read by the modem, it reads it as an EOF indicator. It is also important that the files I send are compressed.
My question is: Does anyone know of a compression format that allows ME to dissallow IT's use of certain ascii chars?
just as an illustration:
Device --------> Modem ---------> Off-site
and the Modem stops talking to the device when a certain char is passed to it.
I am trying to download a EBCDIC file from z/Os to UNIX using FTP in ASCII mode. The problem I am seeing is; when UNIX FTP Client issues a get; UNIX CPU goes to 100% CPU utilization when transferring a file in ASCII mode. I have done packet traces using wireshark and noted that z/OS Server is translating the file to ASCII before putting it on the wire, however when UNIX FTP Client gets the file I believe that the UNIX FTP Client is again translating the file to ASCII causing the 100% CPU utilization. I need verification that this is what is happening, and is there a way of getting around this other then transferring the file in binary mode then doing a EBCDIC
I just uploaded JPG pics from a Win XP, through shell, on my FTP.When I downloaded them back (to a UNIX machine), they were all currupted and unreadable !After some researches, I found that Win XP's shell works by default in ASCII mode.
I had a problem with the old good ascii/binary FTP transfer modes. I transferred some files (SQL scripting files, in which carriage returns DO matter) using FTP from a windows system to a linux system using filezilla "auto" mode, that should have resulted in ASCII mode for my sql files. These files are well formed and identical to the originals.
Then, someone else picked these files and moved them to another ftp server. I finally found that all <CR><LF> couples have been transformed in <CR><CR><LF>. I guessed that the problem was in the ASCII transfer mode - but, how comes that <CR><LF> => <CR><CR><LF>? I would have rather expected <CR><LF> to become <CR>.
I have an application where the client is written in Visual Studio (C#), run on PCs, and the server end has traditionally been SCO. We're now migrating to Linux. I can, for example, input "Test This" in a text box on the client, and when the server end is SCO, it is able to 'accept' the character sent to it from the client. When I try this same example on Linux, that character (hex D1) does not 'make it' from the client to the server.
The problem is not on the client, and I have verified that the telnet connection is in fact passing these extended characters, but they are not recognized properly by the Linux server.In researching this, I've played with setting the LANG environmental variable from LANG=en_US.UTF-8 to several of the other possible values found in /usr/lib/locale, for a european locale (the end user is actually in Spain), and these 'euro' characters are still not handled properly in my application.Would anyone be able to point me to any specific env variable settings, and/or anything else that would resolve this issue?
I've got lines of data in the following format: space1=number of times error has occured space2=IP address space3=Error
I've set this out nicely with printf and made it email me, the problem is - it's not entirely clear what each column/space is and the IP and occurances can sometimes seem confusing. Is there any (easy) way to output this into an ascii like table? There will always be 5 occurances, and the format will always be the same
I'm trying to write a Perl script that will convert text to ASCII. I'm particularly interested in converting files created with MS Windows, so I used Notepad to create a few test files.
I have had some success with the following script: [[ Script Deleted -- see subsequent posts ]]
After coming back /home/ to Debian, I used file to examine the file types: $ file ansi.txt unicode_big-endian.txt unicode.txt utf8.txt ansi.txt: ASCII text, with CRLF line terminators unicode_big-endian.txt: Big-endian UTF-16 Unicode character data, with CRLF line terminators unicode.txt: Little-endian UTF-16 Unicode character data, with CRLF, CR line terminators utf8.txt: UTF-8 Unicode (with BOM) text, with CRLF line terminators
Everything appears good: $ file new_ansi.txt new_unicode_big-endian.txt new_unicode.txt new_utf8.txt new_ansi.txt: ASCII text new_unicode_big-endian.txt: ASCII text new_unicode.txt: ASCII text new_utf8.txt: ASCII text
But the "little-endian file" does not convert properly: $ md5sum new_ansi.txt new_unicode_big-endian.txt new_unicode.txt new_utf8.txt c4def7932bc151b9e786b6ca1299162c new_ansi.txt c4def7932bc151b9e786b6ca1299162c new_unicode_big-endian.txt 5b62a013dced4f2c2c0af45ea6388c1e new_unicode.txt c4def7932bc151b9e786b6ca1299162c new_utf8.txt
When I use cat to print the new_unicode.txt file in an Emacs terminal, a ^@ appears on the last (empty) line. When I open the new_unicode.txt with KWrite, a warning message tells me that the file is a "binary" and "saving it will result in a corrupt file."