string

How do I add my own custom attributes to existing built-in Python types? Like a string?

I want to do something like this... def helloWorld(): print "Hello world!" string.helloWorld = helloWorld "foo".helloWorld() Which would print out "Hello world!" ...

why nResult != nConvertedLen,when use CComBSTR;

CComBSTR wsData = (char*)pvData; when constuct CComBSTR,call A2WBSTR,but sometimes nResult != nConvertedLen,just 1/20. why? inline BSTR A2WBSTR(_In_opt_ LPCSTR lp, int nLen = -1) { if (lp == NULL || nLen == 0) return NULL; USES_CONVERSION_EX; BSTR str = NULL; #pragma warning(push) #pragma warning(disable: 6385) ...

How to create custom filenames in C?

Please see this piece of code: #include<stdio.h> #include<string.h> #include<stdlib.h> int main() { int i = 0; FILE *fp; for(i = 0; i < 100; i++) { fp = fopen("/*what should go here??*/","w"); //I need to create files with names: file0.txt, file1.txt, file2.txt etc //i.e. file{i}.txt } } ...

Regarding String manipulation

I have a String str which can have list of values like below. I want the first letter in the string to be uppercase and if underscore appears in the string then i need to remove it and need to make the letter after it as upper case. The rest all letter i want it to be lower case. "" "abc" "abc_def" "Abc_def_Ghi12_abd" "abc__de" "_" Ou...

Convert a number to its string representation[PHP]

I'm developing a simple web application where in I need to display number a to my users in string format. Example: 12 - One Two or Twelve -20 - minus Two zero or minus twenty Either way is fine. I need this to be done in PHP. Any help will be appreciated. ...

Drawing up a session value within SQL query? PHP and MySQL

Hi, on one of my web pages I want my manager user to view all activities assigned to them (personally). In order to do this, I need something like this: $sql = "SELECT * FROM activities WHERE manager = $_SESSION['SESS_FULLNAME']"; Now obviously this syntax is all wrong, but because I am new to this stuff, is there a way I can call up ...

How can I declare constant strings for use in both an unmanaged C++ dll and in a C# application?

Curently I'm passing my const string values up from my C++ into my C# at startup via a callback, but I'm wondering if there's a way of defining them in a C++ header file that I can then also refer to in C#. I already do this with enums as they are easy. I include a file in both my C++ library project (via a .h file with a pragma once at...

Retrieve string from the middle of a string

I have a coded string that I'd like to retrieve a value from. I realize that I can do some string manipulation (IndexOf, LastIndexOf, etc.) to pull out 12_35_55_219 from the below string but I was wondering if there was a cleaner way of doing so. "AddedProject[12_35_55_219]0" ...

What is the character that represents a null byte after ASCIIEncoding.GetString(byte[])?

I have a byte array that may or may not have null bytes at the end of it. After converting it to a string I have a bunch of blank space at the end. I tried using Trim() to get rid of it, but it doesn't work. How can I remove all the blank space at the end of the string after converting the byte array? I am writing this is C#. ...

String formatting error

Using the code print('{0} is not'.format('That that is not')) in Python 3.1.1, I get the following error: AttributeError: 'str' object has no attribute 'format' when I delete the line Netbeans automatically inserted at the beginning: from distutils.command.bdist_dumb import format which itself causes an error of ImportError: canno...

How do I apply the for-each loop to every character in a String in Java?

So I want to iterate for each character in a string. So I thought: for (char c : "xyz") but I get a compiler error: StackCharTester.java:20: foreach not applicable to expression type How can I do this? ...

String formatting named parameters?

I know it's a really simple question, but I have no idea how to google it. how can I do print '<a href="%s">%s</a>' % (my_url) So that my_url is used twice? I assume I have to "name" the %s and then use a dict in the params, but I'm not sure of the proper syntax? just FYI, I'm aware I can just use my_url twice in the params, but t...

LPCSTR, TCHAR, String

I am use next type of strings: LPCSTR, TCHAR, String i want to convert: from TCHAR to LPCSTR from String to char I convert from TCHAR to LPCSTR by that code: RunPath = TEXT("C:\\1"); LPCSTR Path = (LPCSTR)RunPath; From String to char i convert by that code: SaveFileDialog^ saveFileDialog1 = gcnew SaveFileDialog; saveFileDialog1->...

Easiest way of checking if a string consists of unique characters?

I need to check in Java if a word consists of unique letters (case insensitive). As straight solution is boring, I came up with: For every char in a string check if indexOf(char) == lastIndexOf(char). Add all chars to HashSet and check if set size == string length. Convert a string to a char array, sort it alphabetically, loop through ...

how to find the max index of a string from variable in c#?

suppose i have a string as string[] _strFile; foreach (ListViewItem item in listview1.Items) { string _strRecFileName = item.SubItems[5].Text; _strFile = _strRecFileName.Split('\\'); } in my listview i have a string as \123\abc\hello\.net\*winxp* now i want to get the last value...

Infragistics Webgrid (Datagrid) dynamic adjusting columns

I want to explain this as best as I can. I have a Webgrid with a certain amount of columns. What I want is for the columns to adjust to the size of the largest string within each column, where the total of all width of columns does not exceed the width of the webgrid. At the same time however if the width of all columns is less than the ...

How would you convert a String to a Java string literal?

This is sort of the Java analogue of this question about C#. Suppose I have a String object which I want to represent in code and I want to produce a string literal that maps to the same thing. I was just about to write a state machine that ingests the string character by character and escapes appropriately, but then I wondered if ther...

How to parse a string (by a "new" markup) with R ?

Hi all, I want to use R to do string parsing that (I think) is like a simplistic HTML parsing. For example, let's say we have the following two variables: Seq <- "GCCTCGATAGCTCAGTTGGGAGAGCGTACGACTGAAGATCGTAAGGtCACCAGTTCGATCCTGGTTCGGGGCA" Str <- ">>>>>>>..>>>>........<<<<.>>>>>.......<<<<<.....>>>>>.......<<<<<<<<<<<<." Say that I wa...

inserting std::strings in to a std::map

I have a program that reads data from a file line-by-line. I would like to copy some substring of that line in to a map as below: std::map< DWORD, std::string > my_map; DWORD index; // populated with some data char buffer[ 1024 ]; // populated with some data char* element_begin; // points to some location in buffer char* element...

System.String - why doesn't it implement parameterless constructor?

Hi. I wanted to ask what is the idea behind the fact that System.String doesn't contain parameterless constructor. Because of this you cannot use this type when there is new() constraint. UPDATE Why do you think that new string() is useless and e.g. new int() is not useless. I really cannot see the difference. I really would like to ...