string

null terminator problem while comparing identical char*

i try to compare between 2 char* identical strings,but one of them contains a null terminator at the end. i've been looking through the internet and understood that it's not recommendable to remove the null terminator char cause it will make the string unstable. what other methods can i use? the comparing function: int StringCompare(co...

splitting strings in postgres

I have a string with some spaces in it, and would like to split on the last space, and return the part of the string before that space. Does Postgres support this? I have not been able to solve this with the usual split_part-type functions. Example : "fort worth tx" -> "fort worth" ...

Case for first character of string

I need to make a decision about a string based on the first character, and I have a method defined in this way: (defn check-first [string] (case (get string 0) "+" 1 "-" 2 3 )) Currently it always returns 3 even when the string starts with those characters. What am I doing wrong? Also, is there a more elegant way to ...

Splitting a string in Java

When I split the string "1|2|3|4" using the String.split("|") I get 8 elements in the array instead of 4. If I use "\\|" the result is proper. I am guessing this has something todo with regular expressions. Can anybody explain this? ...

How to convert a string of hex values to a string?

Say I have a string like: string hex = "48656c6c6f"; Where every two characters correspond to the hex representation of their ASCII, value, eg: 0x48 0x65 0x6c 0x6c 0x6f = "Hello" So how can I get "hello" from "48656c6c6f" without having to create a lookup ASCII table? atoi() obviously won't work here. ...

foo.split(',').length != number of ',' found in 'foo'?

Hi, Maybe it's because it's end of day on a Friday, and I have already found a work-around, but this is killing me. I am using Java but am .NET developer. I have a string and I need to split it on semicolon comma. Let's say its a row in a CSV file who has 200 210 columns. line.split(',').length will be sometimes, 199, where count of '...

Ruby Hash bug help!

I'm trying to create a Ruby Hash of objects, where the keys are the object @name member: # m is an object with an @name instance variable (a string) myHash = {} myHash[m.name] = m It's giving this error: #<TypeError: can't convert String into Integer> Anyone know why? I'm sure that m.name is a valid string... ...

Javascript parses in some way the string parameters of functions?

When I try to pass a string to a function like so i="file:///bla/bla/bla"; Fade(i); i get Uncaught SyntaxError: Unexpected token : so i tried passing a literal in the function like f("img1.jpg"); and i got Uncaught ReferenceError: img1 is not defined (anonymous function) What is going on? (note that i am kind of new in js) In pa...

INSERT INTO MySQL and PHP

I have a MySQL table ( members ) with six columns ( FirstName, LastName, Email, username, password, Key) I need to insert a string into the Key column for the username admin How would I go about doing this? ...

Haskell - Do literal backslashes always have to be escaped in a string?

In Haskell, in order to represent the literal string "\", one would normally write: "\\" However, is there a way to escape the string such that a single backslash can be written by itself without needing to be escaped? For example, I can do exactly this in C# by pre-pending @ to the string: @"\" Does Haskell have an equivalent? ...

convert string into signed int

I want to convert a string into a signed int. Following is the requirement. I have stored hex value as a string in buffer. Now I want to convert that value into signed int. buf = "fb869e" Convert this into signed int. So o/p should be -293218. but when I'm trying to convert using strtol I'm getting 16483998. So what I should I do? ...

How to convert this code to use string

char * recursivecombo(char *str, int choices, int level) { int len = strlen(str); level++; if( level == choices) { for (int i = 0; i < len -2; i++) { printf("%c", str[i]) ; } } else { for (int i = 0; i < len - 2; i++) { ...

How to make function return string in c++

Possible Duplicate: How to convert this code to use string I have a function like this: char *foo() { } How can I make it return a string instead? I tried string foo() { } but the compiler complains. ...

mysql_real_escape_string ISSUE

If I type ' into my search bar I get a mysql error as the "sting" has not been escaped- it think. But the reason why I cant escape it is because I dont think it currently is a string. the search box generates search results dynamically with ajax it is as I type and it finds the results that I get the error: You have an err...

c++ string: is there good way to replace a char inside a string

I want to replace all the occurances of ' in a string to ^, but i saw string.replace is not the right function for me, do I need to write my own? It's boring. ...

Strange stack/string behaviour

stack <char> stck; string str; stck.push('0'); str.append("test:"); //test: cout << str << endl; str.append(&stck.top()); //test:0═══════════════¤¤¤¤▌▌▌▌,╘╥XЕ┤ cout << str << endl; Why is this happening? ...

Printing a string in C using a function

I'm brand new to C and am trying to learn how to take a string and print it using a function. I see examples everywhere using while(ch = getchar(), ch >= 0), but as soon as I put it into a function (instead of main()), it ceases to work. Right now, it's stuck in an endless loop... why is that? // from main(): // printString("hello"); v...

How can I convert .strings files to and from .po and .pot files?

How can I convert .strings files to and from .po and .pot files? ...

Why Does SetString Take Less Memory in Delphi (with Unicode)?

This is Delphi 2009, so Unicode applies. I had some code that was loading strings from a buffer into a StringList as follows: var Buffer: TBytes; RecStart, RecEnd: PChar; S: string; FileStream.Read(Buffer[0], Size); repeat ... find next record RecStart and RecEnd that point into the buffer; ...

C++ strange output converting string to int

I'm writing a program that converts a binary string to decimal. I wanted to validate my output before I get really started on this method. I have the following code: int get_val() { int sum =0; for(int num_bits = size; num_bits>0; num_bits--) { printf("String sub %i is %i\n", num_bits, int(bin[num...