string

Index out of bounds of array error when parsing font string?

hello all, i keep getting an "Index is out of bounds of array" error on line # 574 which is: label.Font = new Font(fontNameFields[0], Single.Parse(fontNameFields[1])); ... The following text file i am parsing contains this exact information: Label "hi tyler" 23, 76 Arial,12.5 ...I can successfully parse all the other info (just not...

How does Python's triple-quote string work?

How should this function be changed to return "123456"? def f(): s = """123 456""" return s UPDATE: Everyone, the question is about understanding how to not have \t or whatever when having a multiline comment, not how to use the re module. ...

Open file in TagLib with Unicode chars in filename

Hello, I am quite new to the C++ 'area' so I hope this will not be just another silly 'C++ strings' question. Here is my problem. I want to integrate TagLib (1.5, 1.6 as soon as I manage to build it for Windows) into an existing Windows MFC VS2005 project. I need it to read audio files metadata (not write). The problem is that the pr...

What are the STL string limits?

What are the string limits for the Standard Template Library in C++? ...

Is it possible to force a string to be a specific size when defining a struct?

I am marshalling data between a C# and C++ application. In the C# application, I force the size of a string to be some size (say, 256 bytes). I would like to read in that exact same amount in C++ (I will be recreating the structs with reinterpret_cast) so that the data will remain formatted as it was in the C# application. Unfortunate...

Convert string to Font.

I've been having a hard time trying to get the right answers for my problem. And have spent numerous days searching online and in documentation and have found nothing. I have a Text File that contains a bunch of text. And on one of those lines inside the file will contain some Font info like this: Tahoma,12.5,Regular Note that the fon...

C++ deprecated conversion from string constant to 'char*'

I have a class with a private char str[256]; and for it i have an explicit constructor, explicit myClass(const char *func) { strcpy(str,func); } i call it as, myClass obj("example"); when i compile this i get the following warning: deprecated conversion from string constant to 'char*' can anyone please provide a pointer to this...

How to calculate the font's width?

I am using java to draw some text, but it is hard for me to calculate the string's width. for example: zheng中国... How long will this string occupy? ...

How can I iterate through the unicode codepoints of a Java String?

So I know about String#codePointAt(int), but it's indexed by the char offset, not by the codepoint offset. I'm thinking about trying something like: using String#charAt(int) to get the char at an index testing whether the char is in the high-surrogates range if so, use String#codePointAt(int) to get the codepoint, and increment the...

checking a string for correct characters in c

Is there any easier way to do the following in c? unsigned short check_str(char *str) { while (*str) { if (!(*str == ' ' || *str == '(' || *str == ')' || *str == '1' || *str == '2' || *str == 'a' || *str == 'x' || *str == 'b')) return 0; str++; } return 1; } ...

String comparisons. How can you compare string with std::wstring? WRT strcmp

I am trying to compare two formats that I expected would be somewhat compatible, since they are both generally strings. I have tried to perform strcmp with a string and std::wstring, and as I'm sure C++ gurus know, this will simply not compile. Is it possible to compare these two types? Is there an easy conversion here? ...

C - If/Else and Pointers Returning Wrong String

We have a function longest, which returns the longest substring that consists of letters. Example: longest("112****hel 5454lllllo454") would return: lllllo However, when I run the program it seems to return lllllo454. Here is the function: char *longest(char *s){ char *pMax = NULL; int nMax = 0; char *p = NULL; int n...

string[] management help (C#))

ok, so ill cut to the chase here. and to be clear, im looking for code examples where possible. so, i have a normal string, lets say, string mystring = "this is my string i want to use"; ok, now that i have my string, i split it by the space with string[] splitArray = mystring.Split(new char[] { ' ' }); ok, so now i have splitAr...

What's the difference?

Possible Duplicate: String vs string in C# What's the difference between string and String, if any? They both seem to perform the same funtion, but the casing is different. So, there are only TWO things that are different (that I know of) and they are: When spelled with a capital letter, the color of its text is Blue in VStudi...

Regex to split a string only by the last whitespace character

Hello, hopefully this should be a quick and simple one, using PHP I'm trying to split a string into an array but by only the last instance of whitespace. So far I have... $str="hello this is a space"; $arr=preg_split("/\s+/",$str); print_r($arr); Array ( [0] => hello [1] => this [2] => is [3] => a [4] => space ) ...which split...

Time into string with HH:MM:SS format (C-programming)

I need to get the current time in a "HH:MM:SS"-format into a character array (string) so I can output the result later simply with a printf("%s", timeString); I'm pretty confused on the timeval and time_t types btw, so any explanation would be awesome:) EDIT: So I tried with strftime etc, and it kinda worked. Here is my code: time_t c...

Set a String to "" or leave it null?

I have some String variables which are getting the values from invoking the function getParameter() and some of this variables will probably be null. Later, I will evaluate this variables using equals() method. Should I set all the String variables to the empty String ("") if they are null to avoid any problems? ...

StringBuilder vs String concatenation in toString() in Java

Given the 2 toString() implementations below, which is prefered public String toString(){ return "{a:"+ a + ", b:" + b + ", c: " + c +"}"; } or public String toString(){ StringBuilder sb = new StringBuilder(100); return sb.append("{a:").append(a) .append(", b:").append(b) .append(", c:").append(c) ...

JRuby Array to Java Array

Hey, I am making a site in JRuby on Rails, I am using some Java classes as well. I have a select form element which passes user selections to the controller. The selections are passed like so: Parameters: {"options"=>["Option One", "Option Two"]} The Java method that I am using requires the options selected to be a String[] (Java S...

Asp.Net MVC returning a Json from a string.

Funny as it can sound, I transformed my datatable data into a string which looks something like this: { blocks: [ {"fromAge" : "60","fromAmount" : "0","toAge" : "64","toAmount" : "65000","color" : "red","orderNo" : "2"}, {"fromAge" : "66","fromAmount" : "0","toAge" : "72","toAmount" : "12000","color" : "red","orderNo" : "4"}, {"fromA...