We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › Converting strings to binary...
Page Index Toggle Pages: 1
Converting strings to binary... (Read 777 times)
Converting strings to binary...
Jan 13th, 2010, 8:35pm
 
I'm actually pretty embarrassed to ask this question because it feels like it should be so simple, but I'm building an application that generates glyphs and patterns based on imported text.

It's a project I'd really like to see through, but this is a pretty big part of it.  Wink

Thanks to anyone with any ideas.
Re: Converting strings to binary...
Reply #1 - Jan 13th, 2010, 8:54pm
 
this does the job :


String s = "myString";
String binaryString = "";

for(int i = 0; i<s.length();i++){
binaryString += binary(s.charAt(i));
}

println(binaryString);
Re: Converting strings to binary...
Reply #2 - Jan 13th, 2010, 9:01pm
 
Thank you a million times over Cedric!!  I know I'm new to this, but even still, I can't believe I wasn't able to figure that out.  Of course there would be a binary() that I overlooked.  I should sleep more.  haha!!
Re: Converting strings to binary...
Reply #3 - Jan 13th, 2010, 9:07pm
 
me too, but instead i still hang arround at 6 in the morning to help people Smiley time to go to bed Wink
Re: Converting strings to binary...
Reply #4 - Jan 13th, 2010, 9:14pm
 
Thanks again!  I'll credit you in the comments...
Re: Converting strings to binary...
Reply #5 - Jan 13th, 2010, 9:15pm
 
please not... if i would credit everybody who helped me like this my sourcecode would be much longer Smiley
Re: Converting strings to binary...
Reply #6 - Jan 13th, 2010, 10:42pm
 
Fair enough...  haha...
Page Index Toggle Pages: 1