string

Ruby: How do I join elements of an array together with a prefix?

I have an array like so: ["marblecake", "also", "the", 1337] I would like to get back a string which contains each element of the array prefixed by some specified string, then joined together by another specified string. For example, ["marblecake", "also", "the", 1337].join_with_prefix("%", "__") should result in # => %marblecake_...

Creating C formatted strings (not printing them)

I have a function that accepts a string ( void log_out(char *); ). In calling it, I need to create a formatted string on the fly like: int i = 1; log_out("some text%d", i); How do I do this in ANSI C? ...

Can .NET WebRequest/WebResponse translate accent marks, diacritical marks, and entities correctly?

I am "screen scraping" my own pages as a temporary hack, using .NET's WebRequest. This works well, but accented characters and diacritical characters do not translate correctly. I am wondering if there is a way to make them translate correctly using .NET's many many built in properties and methods. Here is the code I am using to gra...

send json object to jsp

i have a json object in a javascript file. i have to pass this object to a jsp file.the jsp picks up this object and processes it. how can i do it? ...

Engineering notation in C#?

Is there any code out there (or a built-in function) which allows outputting a floating point number in engineering notation? For example, 1.5e-4 would be displayed as 150µ and 5e-3 would be displayed as 5m. ...

How do I PInvoke a multi-byte ANSI string?

I'm working on a PInvoke wrapper for a library that does not support Unicode strings, but does support multi-byte ANSI strings. While investigating FxCop reports on the library, I noticed that the string marshaling being used had some interesting side effects. The PInvoke method was using "best fit" mapping to create a single-byte ANSI...

string.Format throws System.Format exception on HTML + javascript

I'm running string.Format on a readonly string that contains a bit of HTML + javascript but I get a System.FormatException instead. This is my format string: <script type="text/javascript"> function {0}_showHideFieldWindow() { if ({0}.IsCustomizationWindowVisible()) { {0}.HideCustomizationWindow(); } els...

What is a good way to generate short and unique file/folder names?

The criteria is basically this: folders will exist for about 24-48hrs folders names can not be readily guessable by a user (if used in a URL) folder names should be short 5-15 chars Initial thoughts: printf('%u',crc32(microtime(true))); Details: When uploading a file, I basically want to keep the unique file name as named by the u...

Splitting a String into Smaller Parts based on Parens

Using java I am trying to develop a method using recursion to analyze a String of the form: (PART0(PART1(PART2)(PART3))) I want the method to split apart the relevant Strings. I want this method to give me the ability to perform some logic on each part of the String without the parentheses being involved in this order: PART2 PART3 P...

What's the most efficient way to determine whether an untrimmed string is empty in C#?

I have a string that may have whitespace characters around it and I want to check to see whether it is essentially empty. There are quite a few ways to do this: 1 if (myString.Trim().Length == 0) 2 if (myString.Trim() == "") 3 if (myString.Trim().Equals("")) 4 if (myString.Trim() == String.Empty) 5 if (myString.Trim().Equals(Strin...

Java alphabets in different languages

How can I determine if String contains only alphabets and I want to have little more than [a-zA-Z]+, so is there any way to determine alphabets by Locale? ...

Save memory when storing duplicate strings in a vector?

I'm using C++ and it's STL. I have a large (100MB+) text file. This file just has a lot of "words" (strings separated by whitespace) like: sdfi sidf ifids sidf assd fdfd fdfd ddd ddd I need to put each of these "words" in a vector: vector<string> allWordsInFile; So for each word that I read from the file, i do: allWordsInFile.pu...

String concatenation in C# with interned strings

I know this question has been done but I have a slightly different twist to it. Several have pointed out that this is premature optimization, which is entirely true if I were asking for practicality's sake and practicality's sake only. My problem is rooted in a practical problem but I'm still curious nonetheless. I'm creating a bunc...

rails replace path in string

I have a string that may have a path to a file. Example src="/folder/whatever". How do I replace that path with src="http://www.sitename.com/folder/whatever ? ...

Ruby String Translation

I want to find the successor of each element in my encoded string. For example K->M A->C etc. string.each_char do |ch| dummy_string<< ch.succ.succ end However this method translates y->aa. Is there a method in Ruby that is like maketrans() in Python? ...

Is VB6 string comparison case insensitive?

if strValue = 'Hello' then what would be the value of (strValue <> 'HELLO') be? ...

How can I pre-allocate a string in Perl?

I have a Perl script that crunches a lot of data. There are a bunch of string variables that start small but grow really long due to the repeated use of the dot (concatentation) operator. Will growing the string in this manner result in repeated reallocations? If yes, is there a way to pre-allocate a string? ...

how to compare a NSURLconnection http response data with a string value in iphone???

hi......i am new in iphone programming......i want to do an activation module which will send a http request with a PIN numbr and then read the response...if the response is "OK" it opens up with a main menu...........the problem is that i am recieving the response as "OK" but i am unable to compare it with a NSString @"OK"............so...

A way to retrieve all strings from .net project?

Is there a way to list all strings (that are not embeddet in a ressource) in a .net project? I'm particulary interested in messagebox strings etc. so I can check if everything has been translated and written correctly. All tools I have tried so far can only list ressoure strings. Any help very appreciated. Ah forgot to say: I'm a Windo...

best way of replacing all tags in a string with java

I have a service method that takes a String and then replaces tags in the String with items from a tag library. As follows: for( MetaDataDTO tag : tagValues ) { message = message.replace( tag.getKey(), tag.getText1() ); } Obviously; this make heaps of new strings and is BAD. But the StringBuilder replace method is cumbersome to ...