Forums

Skip to content

Advanced search
  • Quick links
    • Unanswered topics
    • Active topics
    • Search
  • FAQ
  • Login
  • Register
  • Board index Assistance Portage & Programming
  • Search

text to ascii converter?

Problems with emerge or ebuilds? Have a basic programming question about C, PHP, Perl, BASH or something else?
Post Reply
Advanced search
12 posts • Page 1 of 1
Author
Message
Farkenell
Tux's lil' helper
Tux's lil' helper
User avatar
Posts: 88
Joined: Fri Dec 05, 2003 12:41 am

text to ascii converter?

  • Quote

Post by Farkenell » Fri Dec 24, 2004 5:14 am

Anyone know of any (having a quick perusal, and look around google didn't find much results?) a quick command line one would be great :)
Top
hjnenc
Veteran
Veteran
User avatar
Posts: 1599
Joined: Sun Aug 15, 2004 5:49 am
Location: Vienna, Austria

  • Quote

Post by hjnenc » Fri Dec 24, 2004 7:05 am

What exactly do you mean by "text" ???
Top
bob_111
Apprentice
Apprentice
Posts: 155
Joined: Tue Oct 12, 2004 7:15 am

  • Quote

Post by bob_111 » Fri Dec 24, 2004 8:06 am

Correct me if im wrong, but isnt text made up of ascii ?
Top
Farkenell
Tux's lil' helper
Tux's lil' helper
User avatar
Posts: 88
Joined: Fri Dec 05, 2003 12:41 am

  • Quote

Post by Farkenell » Fri Dec 24, 2004 8:29 am

err....

kinda like this.... http://www.neurophys.wisc.edu/www/comp/docs/ascii.html
Top
mcdermottpa
Tux's lil' helper
Tux's lil' helper
User avatar
Posts: 95
Joined: Wed Oct 06, 2004 6:02 pm

  • Quote

Post by mcdermottpa » Fri Dec 24, 2004 8:45 am

To clarify, you want to convert a text document to a text document of ascii codes?
Murphy's Military Laws:
#19.There is no such thing as an atheist in a foxhole.
#54. Killing for peace is like screwing for virginity.
Top
hjnenc
Veteran
Veteran
User avatar
Posts: 1599
Joined: Sun Aug 15, 2004 5:49 am
Location: Vienna, Austria

  • Quote

Post by hjnenc » Fri Dec 24, 2004 8:48 am

Farkenell wrote:err....

kinda like this.... http://www.neurophys.wisc.edu/www/comp/docs/ascii.html
Hmm, I still don't know which format you want to convert to ascii code. Lets try it differently: which problem do you have, what do you want to achieve?
Top
andrew_j_w
Guru
Guru
User avatar
Posts: 534
Joined: Sat Jun 28, 2003 11:20 pm
Location: York, UK
Contact:
Contact andrew_j_w
Website

  • Quote

Post by andrew_j_w » Fri Dec 24, 2004 10:57 am

I'm as confused as the other people, but will this do?

Code: Select all

# python
>>> ord("a")
97
>>> ord("z")
122
HTH,
Andrew
Top
tigrezno
Apprentice
Apprentice
User avatar
Posts: 251
Joined: Fri Jun 28, 2002 12:14 pm
Location: Spain
Contact:
Contact tigrezno
Website

  • Quote

Post by tigrezno » Fri Dec 24, 2004 10:57 am

what about "hexdump", it have decimal ouput too
Ruby => "0100007F".unpack('x6a2X4a2X4a2X4a2').collect{ |byte| byte.hex }.join(".")
Top
Farkenell
Tux's lil' helper
Tux's lil' helper
User avatar
Posts: 88
Joined: Fri Dec 05, 2003 12:41 am

  • Quote

Post by Farkenell » Fri Dec 24, 2004 12:43 pm

yeah something like whats been mentioned, I'm not sure what it is called, or what...but I want to pass a string thru a program and it will print out its numerical equiv....basicaly I want a to chuck a string thru a program, and it will print out the results equiv of whats on the left hand side
say I put:
abc
output would be:
097
098
099
Top
multix
Apprentice
Apprentice
User avatar
Posts: 245
Joined: Sun Nov 28, 2004 9:45 am
Location: Italy
Contact:
Contact multix
Website

C code

  • Quote

Post by multix » Fri Dec 24, 2004 12:58 pm

hmm, this seems to be a trivial program, or a I missing something?

I propose something like this:

Code: Select all

#include <stdio.h>

main()
{
  char ch;

  while(!feof(stdin))
  {
     ch = getchar();
     printf("%o\n", ch);
  }
}
to tweak it :
remove "\n" in the printf and substitute it with "\t" or with a blank space if you want results in a row.

This program outputs Octal values, change %o to %x for a hex output, %d for decimal integer and %u for unsigned.

for more info, do "man printf"

the feof() code is a bit rough.
Unix is user friendly. It is only careful selecting its friends.
Top
multix
Apprentice
Apprentice
User avatar
Posts: 245
Joined: Sun Nov 28, 2004 9:45 am
Location: Italy
Contact:
Contact multix
Website

  • Quote

Post by multix » Fri Dec 24, 2004 1:09 pm

Or use hexdump.
Unix is user friendly. It is only careful selecting its friends.
Top
Farkenell
Tux's lil' helper
Tux's lil' helper
User avatar
Posts: 88
Joined: Fri Dec 05, 2003 12:41 am

  • Quote

Post by Farkenell » Fri Dec 24, 2004 4:59 pm

thank you very much I'm looking at em atm, hexdump seems to do what I want, but looks like the code provided maybe able to help me more, with abit of tweaking :)

thank you very much :)

:)
Top
Post Reply

12 posts • Page 1 of 1

Return to “Portage & Programming”

Jump to
  • Assistance
  • ↳   News & Announcements
  • ↳   Frequently Asked Questions
  • ↳   Installing Gentoo
  • ↳   Multimedia
  • ↳   Desktop Environments
  • ↳   Networking & Security
  • ↳   Kernel & Hardware
  • ↳   Portage & Programming
  • ↳   Gamers & Players
  • ↳   Other Things Gentoo
  • ↳   Unsupported Software
  • Discussion & Documentation
  • ↳   Documentation, Tips & Tricks
  • ↳   Gentoo Chat
  • ↳   Gentoo Forums Feedback
  • ↳   Duplicate Threads
  • International Gentoo Users
  • ↳   中文 (Chinese)
  • ↳   Dutch
  • ↳   Finnish
  • ↳   French
  • ↳   Deutsches Forum (German)
  • ↳   Diskussionsforum
  • ↳   Deutsche Dokumentation
  • ↳   Greek
  • ↳   Forum italiano (Italian)
  • ↳   Forum di discussione italiano
  • ↳   Risorse italiane (documentazione e tools)
  • ↳   Polskie forum (Polish)
  • ↳   Instalacja i sprzęt
  • ↳   Polish OTW
  • ↳   Portuguese
  • ↳   Documentação, Ferramentas e Dicas
  • ↳   Russian
  • ↳   Scandinavian
  • ↳   Spanish
  • ↳   Other Languages
  • Architectures & Platforms
  • ↳   Gentoo on ARM
  • ↳   Gentoo on PPC
  • ↳   Gentoo on Sparc
  • ↳   Gentoo on Alternative Architectures
  • ↳   Gentoo on AMD64
  • ↳   Gentoo for Mac OS X (Portage for Mac OS X)
  • Board index
  • All times are UTC
  • Delete cookies

© 2001–2026 Gentoo Foundation, Inc.

Powered by phpBB® Forum Software © phpBB Limited

Privacy Policy

 

 

magic