empty-string

Is empty string valid XML?

Is '' a valid piece of XML? Can '' insert into oracle xblob column or XML column from MSSQL? ...

Comparing a string with the empty string (Java)

Hello, I have a question about comparing a string with the empty string in Java. Is there a difference, if I compare a string with the empty string with == or equals? For example: String s1 = "hi"; if (s1 == "") or if (s1.equals("")) I know that one should compare strings (and objects in general) with equals, and not ==, but I a...

Getting rid of null/empty string values in a C# array

I have a program where an array gets its data using string.Split(char[] delimiter). (using ';' as delimiter.) Some of the values, though, are null. I.e. the string has parts where there is no data so it does something like this: 1 ;2 ; ; 3; This leads to my array having null values. How do I get rid of them? ...

Converting an empty string into nil in Ruby

I have a string called word and a function called infinitive such that word.infinitive would return another string on some occasions and an empty string otherwise I am trying to find an elegant ruby one line expression for the code-snippet below if word.infinitive == "" return word else return word.infinitive Had infinitive re...

In D, how to pass an empty string? (to gtkD)

Using D1 with phobos I have a text entry field, instance of gtk.Entry.Entry, calling setText("") raises a run time error Gtk-CRITICAL **: gtk_entry_set_text: assertion `text != NULL' failed Why? It seems to be a problem with D, I tried this: string empty = ""; assert (empty != null); my_entry.setText(empty) The program terminated...

Is there an option to make Entity Framework revert empty strings to null?

Hi I am using an ADO.NET Entity-Framework ObjectContext to access my data store. I want the if values are set with empty strings, they should automatically become null. ...

Empty XML element handling in Python

I'm puzzled by minidom parser handling of empty element, as shown in following code section. import xml.dom.minidom doc = xml.dom.minidom.parseString('<value></value>') print doc.firstChild.nodeValue.__repr__() # Out: None print doc.firstChild.toxml() # Out: <value/> doc = xml.dom.minidom.Document() v = doc.appendChild(doc.createEleme...

Should I set the initial java String values from null to ""?

Often I have a class as such: public class Foo { private String field1; private String field2; // etc etc etc } This makes the initial values of field1 and field2 equal to null. Would it be better to have all my String class fields as follows? public class Foo { private String field1 = ""; private String field2 = ""; // etc etc et...

HttpWebRequest doesn't work in a web page

I have always used this code to donwload the html source from a web page: private string GetHtml(string url) { HttpWebRequest web = (HttpWebRequest)WebRequest.Create(url); web.Method = "GET"; WebResponse resp = web.GetResponse(); Stream istrm = resp.GetResponseStream(); StreamReader sr = new StreamReader(istrm); string html ...

JSON empty string

Hello everybody, why does the JSON.stringify-Function converts a string.Empty ("") to a "null"-String? The problem, why i'm not using: JSON.parse(json, function(key, value) { if (typeof value === 'string') { if (value == 'null') return ''; return value; } }); ...is, if somebody really write "null" (is very unlikely, ...

Why doesn't COM use a static empty BSTR?

When allocating an empty BSTR, either by SysAllocString(L"") or by SysAllocStringLen(str, 0) you always get a new BSTR (at least by the test I made). BSTRs aren't typically shared (like Java/.NET interment) since they are mutable but an empty string is, for all intents and purposes, immutable. My question (at long last) is why doesn't C...

Set value to null in WPF binding.

Hello, please take a look at the following line <TextBox Text="{Binding Price}"/> This Price property from above is a Decimal? (Nullable decimal). I want that if user deletes the content of the textbox (i.e. enters empty string, it should automatcally update source with null (Nothing in VB). Any ideas on how I can do it 'Xamly'? ...

String.IsNullOrEmpty(myString) Vs myString != null

Which is better to use ? string myString = ""; String.IsNullOrEmpty(myString); or if(myString.Length > 0 || myString != null) EDIT: or if (m.Length > 0 | m != null)** Former is clearer but is there any performance difference in choosing one of above ? What if, in case a string is never empty, like if taken from a Text Box, w...

Is there a way to supress empty space area on RDLC report?

Hi guys depending on information, my report RDLC on Visual Studio 2008 has some fields that are printed or not. I would like to know how could I suppress only this section when there is no data to be printed. I recall that crystal reports has something like that. But what about a RDLC file? thank you ...

SQL Server 2008 - Default column value - should i use null or empty string?

For some time i'm debating if i should leave columns which i don't know if data will be passed in and set the value to empty string ('') or just allow null. i would like to hear what is the recommended practice here. if it makes a difference, i'm using c# as the consuming application. ...

wpf: Data Binding doesn't update when TextBox is Empty

I am Binding a TextBox with a property which is of type float. Everything works fine, I change the value in TextBox and it gets updated in property. The problem occurs when I make the TextBox blank, my property doesn't get updated, it is still having old value. Now I need to use converter in my binding to update property with default val...

return empty string from preg_split

Right now i'm trying to get this: Array ( [0] => hello [1] => [2] => goodbye ) Where index 1 is the empty string. $toBeSplit= 'hello,,goodbye'; $textSplitted = preg_split('/[,]+/', $toBeSplit, -1); $textSplitted looks like this: Array ( [0] => hello [1] => goodbye ) I'm using PHP 5.3.2 ...

StringProperty, None vs. Empty String

class Person(db.Model): first_name=db.StringProperty() middle_name=db.StringProperty() last_name=db.StringProperty() p1=Person(first_name='john', last_name='smith') p2=Person(first_name='john',middle_name=None,last_name='smith') p3=Person(first_name='john',middle_name='', last_name='smith') p1 and p2 is the same...

Perl - Is it good practice to use the empty string as false?

Is it safe/good practice in Perl to use an empty string as false in boolean comparisons? ex: my $s = ''; if($s) { print 'true'; } else { print 'false'; } or would the length function be a better way to go: my $s = ''; if(length($s) > 0) { print 'true'; } else { print 'false'; } ...

How to convert "string" to "*s*t*r*i*n*g*"

I need to convert a string like "string" to "*s*t*r*i*n*g*" What's the regex pattern? Language is Java. ...