string

Memory Efficient Methods To Find Unique Strings

I have a data set that looks like this: 000 100 200 300 010 020 030 001 002 003 001 101 201 301 011 021 031 000 002 003 002 102 202 302 012 022 032 001 000 003 003 103 203 303 013 023 033 001 002 000 010 110 210 310 000 020 030 011 012 013 020 120 220 320 010 000 030 021 022 023 030 130 230 330 010 020 000 031...

php, whats is the different between strtolower and mb_strtolower?

php, whats is the different between strtolower and mb_strtolower? If i want to convert submitted email address, to be converted to lower-case, which one should i use? Is there any email like this : [email protected] If there are such email, should i still convert the submitted email address to lower case? ...

How to parse a string to an integer without library functions?

Hi, I was recently asked this question in an interview: "How could you parse a string of the form '12345' into its integer representation 12345 without using any library functions, and regardless of language?" I thought of two answers, but the interviewer said there was a third. Here are my two solutions: Solution 1: Keep a dictiona...

Should I use \r or \n for explode()ing the contents of a file in PHP?

I'm creating a function which can accept a string which is either retrieved through file_get_contents() on a local text file, or something fetched from a url such as http://site.com/338383.txt. The file will be a tab seperated file, with each item in the file being on its own line. Is it better to use \n or \r to explode() the string an...

How do I generate character sequences like hexadecimal with a different base?

I have the following Perl script that generates a string based on a number: my @chars; push @chars, map(chr, 48..57), map(chr, 97..122); my $c = $#chars+1; for (0..50) { my $string; my $l = $_ / $c; my $i = int $l; my $r = ($l - $i) * $c; $string .= $chars[$r]; while ($i > 0) { $l = $i / $c; $i =...

Why is strncpy insecure?

I am looking to find out why strncpy is considered insecure. Does anybody have any sort of documentation on this or examples of an exploit using it? ...

string + db table to populate values in gridview.

Hi, I've have a string with prodIDs like "3, 16, 12" is it possible to match these Ids with the product table in the db and display details like name, price in the gridview? PS: im new to c# and asp.net! thanks, ...

Most Efficient Way to Find Whether a Large List Contains a Specific String (Python)

Hello, I have a file containing roughly all the words in English (~60k words, ~500k characters). I want to test whether a certain word I receive as input is "in English" (i.e. if this exact word is in the list). What would be the most efficient way to do this in Python? The trivial solution is to load the file into a list and check wh...

Print space after each word

Hi, what is an easy/effective way to combine an array of words together with a space in between, but no space before or after? I suppose it is possible to remove the space after combining everything in a loop (something like sum += (term + " "))...I don't like it though. Preferably code in Java, Python, or Ruby. Thanks! ...

find if string endswith another string c++

How to find if string endswith another string c++ ...

C++ std::string conversion problem on Windows

Hello, This is my procedure: bool Open(std::string filename) { ... HANDLE hFile = CreateFile(filename.c_str(), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL); ... } Error:'CreateFileW' : cannot convert parameter 1 from 'const char *' to 'LPCWSTR' Types pointed to are unrelated; conversion requires re...

String and Final

What is difference between in the following statements String name = "Tiger"; final String name ="Tiger"; Although the String class is final class, why do we need to create a String "CONSTANT" variable as final? ...

Visual Basic - How do I store strings permanently? After the app is closed?

Hi, I'm trying to figure out how to do this as I'm not sure what's the proper way of doing this. I've got several strings that I want to store/save permanently, even after the application is closed. How should I proceed? Do I read or write from a textfile? ...

How to measure characters in javascript and/or with jquery

I need to write in javascript (jquery) a function that is aware of the number of characters that fit in a line of the browser window. I'm using a monospace font to ease the problem, but it would be better if I generalize it for different fonts. How can I know how many characters would fill a row in the browser? The intention is to coun...

Is comparing string sizes an acceptable alternative to comparing characters?

I'm writing a grep function in C++ (as a self assigned exercise - I realize this doesn't have the functionality of an actual grep feature) to take an original string and the search string you are looking for. In the code, I enter all the characters in a grep string up to the first space it sees. Then I compare the characters in the grep ...

How to remove symbols from a string with Python?

I'm a beginner with both Python and RegEx, and I would like to know how to make a string that takes symbols and replaces them with spaces. Any help is great. For example: how much for the maple syrup? $20.99? That's ricidulous!!! into: how much for the maple syrup 20 99 That s ridiculous ...

How to reuse a string variable in c++

Hi Is this correct, it works OK string str("in.dat"); ifstream fin(str.c_str(), ios::binary | ios::ate ); . . . //Do I need to clear the string before assigning new name??? str = "out.dat"; ofstream fout(str.c_str(), ios::binary); //seems to work Regards ...

Copy a streambuf's contents to a string

Apparently boost::asio::async_read doesn't like strings, as the only overload of boost::asio::buffer allows me to create const_buffers, so I'm stuck with reading everything into a streambuf. Now I want to copy the contents of the streambuf into a string, but it apparently only supports writing to char* (sgetn()), creating an istream with...

compare buffer with const char* in C++

What is the correct C++ way of comparing a memory buffer with a constant string - strcmp(buf, "sometext") ? I want to avoid unnecessary memory copying as the result of creating temporary std::string objects. Thanks. ...

Using a string as Function name

Hi I have to made a generic function which is used for the purpose of calling many other functions depending upon the accesses im getting. For Ex: def func1 @access = ['public','private','protected'] for acc in @access @temp = "get_"+acc[1]+"_data" end end def get_public_data end def get_private_data end def get_pro...