string

The string "Test '<3'" displays as "Test '<3>" in my Rails app

I'm having a strange problem where a user can enter the following text Test '<3' and it outputs as Test '<3> On the output I'm using white_list, and the value stored in the database is: 'testing ''<3''' What could be causing the output to think it's a tag of some sort and trying to close it (which is what it looks like ...

Groovy String Concatenation

Current code: row.column.each(){column -> println column.attributes()['name'] println column.value() } Column is a Node that has single attribute and a single value. I am parsing an xml to input create insert statements into access. Is there a groovy way to create the following structured statement: Insert INTO...

What encoding does std::string.c_str() use?

I am trying to convert a C++ std::string to UTF-8 or std::wstring without losing information (consider a string that contains non-ASCII characters). According to http://forums.sun.com/thread.jspa?threadID=486770&amp;forumID=31: If the std::string has non-ASCII characters, you must provide a function that converts from your encoding ...

Is it possible to modify a string of char in C?

I have been struggling for a few hours with all sorts of C tutorials and books related to pointers but what I really want to know is if it's possible to change a char pointer once it's been created. This is what I have tried: char *a = "This is a string"; char *b = "new string"; a[2] = b[1]; // Causes a segment fault *b[2] = b[1]; //...

Comparing a string to an array in objective-C

Dear all, here's a very basic question, that I'm sure you will be able to answer quickly. Please don't laugh at my ignorance. I have a string, that I want to compare to an array of strings. Only if the string is not part of the array, I want to perform an operation. I tried the following code, that doesn't work. I do understand why, bu...

Variables with respect to DOM

This is surely a JS beginner question. My issue is I want to use the value of the variable type to access the relevant checkbox; however it is treating the variable as a string. I have tried it to two ways. function toggleGroup(type) { if (document.getElementById(type).checked == true){ alert("foo"); } } or function ...

How to concatenate strings with binary values in python?

What's the easiest way in python to concatenate string with binary values ? sep = 0x1 data = ["abc","def","ghi","jkl"] Looking for result data "abc0x1def0x1ghi0x1jkl" with the 0x1 being binary value not string "0x1". ...

std::string to float or double

Hello, i'm trying to convert std::string to float/double. I tried: std::string num = "0.6"; double temp = (double)atof(num.c_str()); But it always returns zero. Any another ways? You could see debugger result in this screen: ...

What does : TypeError: cannot concatenate 'str' and 'list' objects mean?

What does : TypeError: cannot concatenate 'str' and 'list' objects mean?? I'm getting this error.. and I know it's saying I'm trying to add a string and a number maybe? but I'm not sure how to fix it Here's part of the code: for j in ('90.','52.62263.','26.5651.','10.8123.'): if j == '90.': z = ('0.') elif j == '52.62...

Difference in writing string vs. char array with System.IO.BinaryWriter

I’m writing text to a binary file in C# and see a difference in quantity written between writing a string and a character array. I’m using System.IO.BinaryWriter and watching BinaryWriter.BaseStream.Length as the writes occur. These are my results: using(BinaryWriter bw = new BinaryWriter(File.Open(“data.dat”), Encoding.ASCII)) { stri...

how to evaluate formula passed as string in php?

Just trying to figure out the proper and safer way to execute mathematic operation passed as string. In my scenario it is values fetched from image EXIF data. After little research I found two way of doing it. first, using eval: function calculator1($str){ eval("\$str = $str;"); return $str; } second, using create_function: ...

Regex-like syntax or CFG for generating cartesian product of concatenated string variables and literals

I am writing a simulator, and would like to run studies by invoking a lot of instances of the simulator, using different sets of command-line arguments. I have read this question and several others, and they seem close, but I'm actually not looking for random data fulfilling a particular regex, I would like the set of all strings that m...

Scanning all elements of an array in GAWK returns numbers instead of values

Given the following function: function process_pipes(text) { split(text,recs,"|"); for (field in recs){ printf ("|%s|\n", field) } } If the input is: 0987654321|57300|ERROR account number not found|GDUMARESQ|0199|9|N|0|| Why do I get the numbers below instead of the text? |4| |5| |6| |7| |8| |9| |10| |1| |2| |3|...

Finding tokens in a Java String

Is there a nice way to extract tokens that start with a pre-defined string and end with a pre-defined string? For example, let's say the starting string is "[" and the ending string is "]". If I have the following string: "hello[world]this[[is]me" The output should be: token[0] = "world" token[1] = "[is" (Note: the second token ha...

How can I expand a string like "1..15,16" into a list of numbers?

I have a Perl application that takes from command line an input as: application --fields 1-6,8 I am required to display the fields as requested by the user on command line. I thought of substituting '-' with '..' so that I can store them in array e.g. $str = "1..15,16" ; @arr2 = ( $str ) ; @arr = ( 1..15,16 ) ; print "@arr\n" ; pri...

Truncate a VARCHAR to specific length in Derby AUTOMATICALLY

How can I truncate a VARCHAR to the table field length AUTOMATICALLY in Derby using SQL? To be specific: CREATE TABLE A ( B VARCHAR(2) ); INSERT INTO A B VALUES ('1234'); would throw a SQLException: A truncation error was encountered trying to shrink VARCHAR '123' to length 2. Is there a easy way to suppress this exception? ...

php to extract a string from double quote

I have a string This is a text, "Your Balance left $0.10", End 0 how can i extract the string in between double quote and have only the text 'Your Balance left $0.10' (without the double quotes) Tried preg_match_all but no luck ...

Can I use string "IsEmpty" methods in Delphi.

Embaracdero documents "IsEmpty" methods for string types, which I've used successfully with C++ Builder code. WideString s; if (s.IsEmpty()) .... I tried the same from Delphi, and couldn't get it to compile: var s: WideString; begin if s.IsEmpty then .... I know you can compare with an empty string, or call the Length func...

How to convert object array to string array in Java

I use the following code to convert an object array to a string array : Object Object_Array[]=new Object[100]; // ... get values in the Object_Array String String_Array[]=new String[Object_Array.length]; for (int i=0;i<String_Array.length;i++) String_Array[i]=Object_Array[i].toString(); But I wonder if there is another way to do thi...

ASP.NET: Shortest way to render DataTable to a string (HTML)?

What is the shortest way to convert a DataTable into a string (formatted in HTML)? Programmatically binding to a UI control and rendering to an ASP.NET page is not acceptable. Can't depend on the ASP.NET page lifecycle. The purpose of this shouldn't matter, but to satisfy curiosity: This is for logging/debugging/dump purposes in algo...