Testing out someone elses code (of course it was ...) ,
I noticed a few JSP pages printing funky non-ascii characters. Taking a dip into the source I found this tidbit.
// remove any periods from first name e.g. Mr. John --> Mr John
firstName = firstName.trim().replace('.','\0');
Does replacing a character in a String with a null ch...
Hi, I was wondering how you could take 1 string, split it into 2 with a delimiter, such as space, and assign the 2 parts to 2 separate strings. I've tried using strtok(); but to no avail.
Thanks!
Mr. Man
...
I have a very simple function that takes a list of comma separated (x,y) points and imports them into a graph. I have FF, Chrome and IE8 installed. I use IETester to test for IE6 and IE7.
// Import Data
this.Import = function(data) {
alert("Data in: "+data);
var d;
// Make sure the first and the last are start/ending pare...
Hi there,
I'm trying to merge a hash with the key/values of string in ruby.
i.e.
h = {:day => 4, :month => 8, :year => 2010}
s = "/my/crazy/url/:day/:month/:year"
puts s.interpolate(h)
All I've found is to iterate the keys and replace the values. But I'm not sure if there's a better way doing this? :)
class String
def interpolate...
I have a function:
char *make_text(void)
{
char txt[MAXLEN];
//make something
return txt;
}
Thats my main program:
int main(void)
{
char *s = make_text();
puts(s);
getch();
return 0;
}
puts(s) returns 0 and its nothing printed. Whats happened?
...
I have a 'Title' column with abbreviations (Ceo, Cio,..) which I have to capitalize. What is the most efficient way of finding 3 lettered words and capitalizing them?
Sample data :
Title
-----------------------
Vp - business, Cio, Ceo
E Vp, Cfo
Ceo
Cio
Vp
Thank you so much!
...
Whats The use of function strtok()in PHP, how is better than other string function doing the same thing?
...
Solution:
strpos turned out to be the most efficient. Can be done with substr but that creates a temporary substring. Can also be done with regex, but slower than strpos and does not always produce the right answer if the word contains meta-characters (see Ayman Hourieh comment).
Chosen answer:
if(strlen($str) - strlen($key) == strrpo...
Suppose I have a sting as "PHP Paddy,PHP Pranav,PHP Parth", now i have a count as 3,now how should I iterate loop in the string aiming on string after "PHP " to display the all the names?
Alright This is the string "BEGIN IF (NEW.name != OLD.name) THEN INSERT INTO jos_menuaudit set menuid=OLD.id, oldvalue = OLD.name, newvalue = NEW.name...
I'm writing a script to perform an offsite rsync backup, and whenever the rsyncline recieves some output it goes into a single variable. I then want to split that variable into an array upon the ^M token, so that I can send them to two different logger-sessions (so I get them on seperate lines in the log).
My current line to perform the...
PHP beginner's question.
I need to keep image paths as following in the database for the admin backend.
../../../../assets/images/subfolder/myimage.jpg
However I need image paths as follows for the front-end.
assets/images/subfolder/myimage.jpg
What is the best way to change this by PHP?
I thought about substr(), but I am wonderi...
I want to sort a String that has nr. How do I do that?
Lets say my integers are
Class2
"3"
"4"
"1"
in main I do class2.Sort();
Thanks in Advance.
...
i got this code
$current_path = str_replace('\', '/', getcwd()); //c://xampp/htdoc
Why it fail replace '\' with '/' in directory patch ? why is the reason and how to handle this problem ?
EDIT This code use to return path (or something like that) use with HTML TAG base.
$current_path = getcwd();
function get_basepath() { ...
I have this function:
void ToUpper(char * S)
{
while (*S!=0)
{
*S=(*S >= 'a' && *S <= 'z')?(*S-'a'+'A'):*S;
S++;
}
}
What does it mean for *S != 0, should it be null instead?
...
How do I add colour to my text in canvas. When I tried fillStyle the text just stayed black.
...
I have a string like 20090101 and I want to compare it with ????01??.
if (input == "----01--") { .... }
How can I compare the 5th and 6th characters with "01"?
...
I am trying to read strings from a file that has each string on a new line but I think it reads a newline character once instead of a string and I don't know why. If I'm going about reading strings the wrong way please correct me.
i=0;
F1 = fopen("alg.txt", "r");
F2 = fopen("tul.txt", "w");
if(!feof(F1)) {
do{ //start sc...
Suppose I have this code:
String encoding = "UTF-16";
String text = "[Hello StackOverflow]";
byte[] message= text.getBytes(encoding);
If I display the byte array in message, the result is:
0000 FE FF 00 5B 00 48 00 65 00 6C 00 6C 00 6F 00 20 ...[.H.e.l.l.o.
0010 00 53 00 74 00 61 00 63 00 6B 00 4F 00 76 00 65 .S.t.a.c....
Hey all,
I try to use single quotes as much as possible and I've noticed that I can't use \n in single quotes. I know I can just enter a newline literally by pressing return, but that screws up the indentation of my code.. Is there some ASCII character or something that I can type that will produce newline when I'm using single quotes?
...
My current project involves gathering text content from an element and all of its descendents, based on a provided selector.
For example, when supplied the selector #content and run against this HTML:
<div id="content">
<p>This is some text.</p>
<script type="text/javascript">
var test = true;
</script>
<p>This is some more...