string

How to copy string into fixed length string in C++

I have a string which I want to copy into a fixed length string. For example I have a string s = "this is a string" that is 16 characters long I want to copy this into a fixed length string s2 that is 4 characters long. So s2 will contain "this" I also want to copy it into a fixed length string s3 that is 20 characters long. The end...

C char to string (passing char to strcat())

hi all, my problem is in convert a char to string i have to pass to strcat() a char to append to a string, how can i do? thanks! #include <stdio.h> #include <string.h> char *asd(char* in, char *out){ while(*in){ strcat(out, *in); // <-- err arg 2 makes pointer from integer without a cast *in++; } return out;...

C++/CLI Converting System::String to const char*

I'm using Microsoft Visual C++ 2008 I want to join some strings, and then use it with "system" command. I tried to do it like this: System::String^ link; link = "wget.exe --output-document=log http://ADDRESS"; link = link + System::String::Copy(textBox_login->Text); link = link + "&passwd="; link = link + System::String::Copy(textBox_p...

How to convert an ASCII string to an UTF8 string in C++?

How to convert an ASCII std::string to an UTF8 (Unicode) std::string in C++? ...

What's wrong with this string normilizer Python snippet?

It seems that every time I think I mastered encoding, I find something new to puzzle me :-) I'm trying to get rid of French accents from an UTF-8 string: >>> import unicodedata >>> s = u"éèêàùçÇ" >>> print(unicodedata.normalize('NFKD', s).encode('ascii','ignore')) I expected eeeaucC as an output and got instead AA AaA A1AA using Py...

MooTools. Convert XML (Elements) to String

I need to consume XML based RESTful API. All request are sent in XML format. I've been using MooTools extensions to build XML requests. However, I don't know how to transform it string, so that I could send the XML directly to server. var reqEl = new Element('req'); var loginEl = new Element('login'); var usernameEl = new Element('usern...

String array in C++ not working properly?

I'm working on a program for class that takes in a number from 0 to 9999, and spits out the word value (ie 13 would be spit out as "thirteen", etc) And I'm having a pain with the array for some reason. Here is the class so far: #include<iostream> #include<string> using namespace std; class Numbers { private: int number;...

serialize function for string values to use in jQuery ajax datastring

how to sanitize user inputs that you gather by jquery .val() so you can write it in a dataString... in the example you see below when user writes if some text that contains & the rest of the comment doesn't seem to work fine because it counts the rest as an other variable to POST.. is there a sanitaziation or serialization co...

How do I print a line following a line containing certain text in a saved file in Python?

I have written a Python program to find the carrier of a cell phone given the number. It downloads the source of http://www.whitepages.com/carrier_lookup?carrier=other&amp;number_0=1112223333&amp;response=1 (where 1112223333 is the phone number to lookup) and saves this as carrier.html. In the source, the carrier is in the line after the...

C++/CLI Converting System::Object ^ to std::basic_string<_Elem,_Traits,_Ax>

I have a listBox in Visual C++ 2008, and I want the first line convert to string. So first, I select the first line listBox1->SetSelected( 0, true ); And afterwards, I want to convert it to string string t = listBox1->SelectedItems[ 0 ]; Which results in an error: error C2440: 'initializing' : cannot convert from 'System::Obje...

Fuzzy Regular Expressions

In my work I have with great results used approximate string matching algorithms such as Damerau–Levenshtein distance to make my code less vulnerable to spelling mistakes. Now I have a need to match strings against simple regular expressions such TV Schedule for \d\d (Jan|Feb|Mar|...). This means that the string TV Schedule for 10 Jan s...

Can't use unichr in Python 3.1

Hi, new here! I'm a beginner in Python, and I've been looking through the Python Cookbook (2nd Edition) to learn how to process strings and characters. I wanted to try converting a number into its Unicode equivalent. So I tried using the built-in function called 'unichr', which, according to the Cookbook, goes something like: >>> prin...

If string only contains spaces?

How can i check to see if a string only contains spaces? ...

question about javascript string's replace method

Hi guys, I know that I can pass a string as the second parameter to the JavaScript string object's replace method. In this case I can use $` and $' to reference the left/right part text of a successful match. Now my question is, If I pass a callback function as the second parameter, how can I get the same information? I want to use this...

How can I convert string to "command" in Python?

How can I convert this so it could execute? Traceback (most recent call last): File "C:\Users\Shady\Desktop\tet.py", line 14, in <module> exec test File "<string>", line 1 print "hello world" ^ IndentationError: unexpected indent source: test = ''.join(clientIp.split("test6")[1:]) ...

Iterate Hash Map

I have an hashmap declared as private HashMap testMessages = null; I will be storing string values in both key and value part of the hashmap retrieved from oracle table. I am not concerned about the hashmap keys. I want to retrieve the hashmap values alone and check whether string variable filename is prefixed with one of the hash ma...

get value from javascript object

when alerting a variable in javascript it shows like this.. totally 9 values(name, address, city, friend etc) how to retrive the values [object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object] ...

ereg_replace missing square brackets?

Hey I have the following code that should strip all non alphanumerics (excluding hyphens) from some text. It does however miss square brackets somehow? ereg_replace('[^A-z0-9-]', '', strtolower(str_replace(' ','-',$title))) Can anyone advise? ...

Java: Parse Australian Street Addresses

Looking for a quick and dirty way to parse Australian street addresses into its parts: 3A/45 Jindabyne Rd, Oakleigh, VIC 3166 should split into: "3A", 45, "Jindabyne Rd" "Oakleigh", "VIC", 3166 Suburb names can have multiple words, as can street names. See: http://stackoverflow.com/questions/1739746/parse-a-steet-address-into-compon...

string tokenizer in Java

I have a text file which contains data seperated by '|'. I need to get each field(seperated by '|') and process it. The text file can be shown as below : ABC|DEF||FGHT I am using string tokenizer(JDK 1.4) for getting each field value. Now the problem is, I should get an empty string after DEF.However, I am not getting the empty space b...