string

Deallocation of String type of an object as it resides in String Pool

We know that for any other objects GC will take care of deallocation. but what happens to a String objects which resides in String pool. who will decide it to deallocate and who actually does it? because we know that there will be String literals still present even after dereferencing it. ...

Ruby String Integer Scanning

Is there a Ruby equivalent of the Java Scanner? If I have a string like "hello 123 hi 234" In Java I could do Scanner sc = new Scanner("hello 123 hi 234"); String a = sc.nextString(); int b = sc.nextInt(); String c = sc.nextString(); int d = sc.nextInt(); How would you do this in Ruby? ...

Convert Unicode to ASCII without changing the string length (in Java)

What is the best way to convert a string from Unicode to ASCII without changing it's length (that is very important in my case)? Also the characters without any conversion problems must be at the same positions as in the original string. So an "Ä" must be converted to "A" and not something cryptic that has more characters. Edit: @novali...

In Javascript or jQuery, how to detect whitespace in beginning of string?

Given the following string: htmlStr1 = " <div>This is a string with whitespace in the beginning</div> "; htmlStr2 = "<div>This is a string with no whitespace in the beginning</div> "; Is there a way to write a function that can detect if this string has a whitespace in the very beginning only? e.g., it should do the following: alert...

What exactly is a PWSTR and why use this naming compared to char*, std::string, or CString in C++?

In various c++ code you often see different usage of strings: PWSTR, char*, std::string, CString, etc ... When is the best time to use PWSTR as compared to any other string type? ...

Java unreadable strings

Hello all, I have made a java socket listener which listens on port 80. And what is basically does is it gathers the data that it listens on port 80 and stores it in a temporary string which is then used for further operation(type conversions et all). Now the basic problem is that the data that comes on port 80 has parts that are unread...

Find text in string in PHP

This should be pretty straightforward, but I can't seem to find an explanation anywhere on how to do it. I have a string in PHP. That string might contain within it somewhere the substring ":ERROR:". I need to find if it has that string. strpos() has worked perfectly up to this point, until today when ":ERROR:" was the first item in th...

Which one to use const char[] or const std::string?

Which is better for string literals, standard string or character array? I mean to say for constant strings, say const char name[] = "so"; //or to use const string name = "so"; ...

How to find all substrings of a string

I need to convert strings of the form "a b c" into arrays of the form Array ( [0] => a [1] => a b [2] => a b c [3] => b [4] => b c [5] => c ) Does PHP provide a native function for converting strings into all substrings? If not, what's the path of least resistance for getting all substrings? Is there a str...

Getting fuzzy string matches from database very fast

Hello. I have a database of ~150'000 words and a pattern (any single word) and I want to get all words from the database which has Damerau-Levenshtein distance between it and the pattern less than given number. I need to do it extremely fast. What algorithm could you suggest? If there's no good algorithm for Damerau-Levenshtein distanc...

Difference between .ToString and "as string" in C#

What is the difference between using the two following statements? It appears to me that the first "as string" is a type cast, while the second ToString is an actual call to a method that converts the input to a string? Just looking for some insight if any. Page.Theme = Session["SessionTheme"] as string; Page.Theme = Session["SessionThe...

Hash quality and stability of String.GetHashCode() in .NET?

I am wondering about the hash quality and the hash stability produced by the String.GetHashCode() implementation in .NET? Concerning the quality, I am focusing on algorithmic aspects (hence, the quality of the hash as it impacts large hash-tables, not for security concerns). Then, concerning the stability, I wondering about the poten...

Performance replacement for String in Java

Hi Anyone remembers the name of that opensource "project" that developed some nice replacement for String in java ? I know there is is one, just cant find it in google and dont remember the name. (i am not talking about StringBuilder) Thanks ...

how can I generate strings that satisfy some restrictions?

Can anyone give me a hand with techniques to generate strings that satisfy certain restrictions. For example, say I need to generate strings s and t such that length(s) < length(t) length(t) > 12 t contains at least 3 capital letters and s contains a 2 And I don't mean this particular example but some generic tec...

save string array in binary format

string value1 , value1 ; int length1 , length2 ; System.Collections.BitArray bitValue1 = new System.Collections.BitArray(Length1); System.Collections.BitArray bitValue2 = new System.Collections.BitArray(Length2); I'm looking for the fastest way to covert each string to BitArray with defined length for each string (the string should be ...

URL Friendly Username in PHP?

On my PHP site, currently users login with an email address and a password. I would like to add a username as well, this username they g\set will be unique and they cannot change it. I am wondering how I can make this name have no spaces in it and work in a URL so I can use there username to link to there profiles and other stuff. If ...

convert very small double to a String

hi, I have a very small number and I want to convert it to a String with the full number, not abbreviated in any way. I don't know how small this number can be. for example, when I run: double d = 1E-10; System.out.println(d); it shows 1.0E-10 instead of 0.000000001. I've already tried NumberFormat.getNumberInstance() but it format...

str.each in Ruby isn't working

I'm Learning Ruby. I found the method String#each at http://ruby-doc.org/core/classes/String.html. When I try using it... irb(main):001:0> "hello\nworld".each {|s| p s} NoMethodError: undefined method `each' for "hello\nworld":String ...but I get that NoMethodError. I'm using Ruby 1.9.1p253 so I don't think I'm using an old versi...

Whats the best way to send QStrings in a function call?

I would like to know what is the most efficient and practical way of sending a Qstring as a parameter to a function, in QT more specifically. I want to use a reference. The problem is I also want to instantiate that string in the function itself like so for example: this is the function prototype: void myFunction(QString & theMsg); th...

Dynamic Connection String for a Strongly Typed Dataset

I have an asp.net nTier application. The data access layer is a strongly typed DataSet consisting of multiple DataTables with DataAdapters. When the user logs in, they choose which database to connect to (from a table in the membership database). I need to pass the selected connection string into the DataSet object which will remain the ...