conversion

How do I avoid compiler warnings when converting enum values to integer ones?

I created a class CMyClass whose CTor takes a UCHAR as argument. That argument can have the values of various enums (all guaranteed to fit into a UCHAR). I need to convert these values to UCHAR because of a library function demanding its parameter as that type. I have to create a lot of those message objects and to save typing effort I ...

I need info on conversion from base 10 to any number base and vice versa (not using the c# library)

E.g. Integer to Hexa, Integer to Octal Integer to binary and so on.... and vice versa ...

How to read and modify the colorspace of an image in c#

I'm loading a Bitmap from a jpg file. If the image is not 24bit RGB, I'd like to convert it. The conversion should be fairly fast. The images I'm loading are up to huge (9000*9000 pixel with a compressed size of 40-50MB). How can this be done? Btw: I don't want to use any external libraries if possible. But if you know of an open sourc...

How to read EMF - Enhanced metafiles?

Does anybody know of a library or a piece of code that can read EMF (Enhanced Metafiles). Ideally it would convert an EMF to a list of drawing commands and objects? ...

In C# VS2008 how to replace (string)aaa to aaa.ToString()

I just converted a VB.net solution into C# solution. But lots of variables have been coverted like: string var1 = (string)1; string var2 = (string)intVar; //intVar is a int value I just want to convert all (string)XXXX to XXXX.ToString() by using some Regular expressions or some other replace methods. Can someome help me out? ...

In C# VS2008 how to replace intA = (int)obj.GetStr("xxx"); to intA = int.Parse(obj.GetStr("xxx"));

In C# VS2008 how to replace intA = (int)obj.GetStr("xxx"); to intA = int.Parse(obj.GetStr("xxx")); I have thounds of lines code have this pattern. I just want to pass compile by using some regular expression. ...

NSString newbie question about setting a char from it.

Ok, I know this is a very basic question, but my head is swimming in NSString vs C string nonsense. Basically I have a NSString the just contain 1 character for example the letter D How do I take that 1 character NSString and assign it to a variable of char So I have... char mychar; NSString *myMode = [[NSString alloc] initWithFo...

C# Can't get String to DateTime conversion to work

Hi, I've done some simple string -> DateTime conversions before using DateTime.ParseExact(), but I have a string that I can't seem to get parsed properly. I'm probably doing something very obvious wrong but I just can't see what it is. The code is as follows: string date = "Tue Jun 23, 2009 2:23 pm"; DateTime lastupdate = DateTime.Par...

Convert a string to integer with decimal in Python

I have a string in the format: 'nn.nnnnn' in Python, and I'd like to convert it to an integer. Direct conversion fails: >>> s = '23.45678' >>> i = int(s) Traceback (most recent call last): File "<stdin>", line 1, in <module> ValueError: invalid literal for int() with base 10: '23.45678' I can convert it to a decimal by using: >>> ...

Is there a better way to determine if a string can be an integer other than try/catch?

I needed a function that simply checks if a string can be converted to a valid integer (for form validation). After searching around, I ended up using a function I had from 2002 which works using C#1 (below). However, it just seems to me that although the code below works, it is a misuse of try/catch to use it not to catch an error but...

How do I convert a System::String^ to const char*?

I'm developing an app in C++/CLI and have a csv file writing library in unmanaged code that I want to use from the managed portion. So my function looks something like this: bool CSVWriter::Write(const char* stringToWrite); ...but I'm really struggling to convert my shiny System::String^ into something compatible. Basically I was hopi...

Convert HTML to XAML

Is there a way to convert HTML into XAML? I noticed that you can paste HTML into a RichTextBox and you can get the XAML by looking at the FlowDocument. However, this is a hack. Is there a better way? ...

Generate low-order non-printable characters from XLST

I'm trying to use XSLT text output to generate a file (in a file format that I'm not in control of), and while it is mostly text, it includes low-order non-printable characters as flags, including characters that are not valid within an XLST file (according to the XSLT specification). I'd like for something like the below to work, but i...

How to convert a DataTable to a string in C#?

Hi there, I'm using Visual Studio 2005 and have a DataTable with two columns and some rows that I want to output to the console. I hoped there would be something like: DataTable results = MyMethod.GetResults(); Console.WriteLine (results.ToString()); What's the best way (i.e. least amount of coding from me) to convert a simple DataTa...

PHP and FFMPEG - Performing intelligent video conversion

I have an oddly difficult task to perform. I thought it would be easy, but all my efforts have been fruitless. I'm converting videos uploaded to a php script from various formats (.avi, .mpg, .wmv, .mov, etc.) to a single .flv format. The conversion is working great but what I'm having trouble with is the resolution of the videos. Th...

Using code written for the serial port on an usb port

Hi all :) I've got an USB card reader that I need to access from Lazarus / Delphi. The SDK is written in VB6 and talks to the serial port, so in Windows it installs a driver to map the USB port to a serial port. I'd like to skip that step (eg so that the same code works in Linux), but I'm not very familiar with the USB protocol, so I ...

Built-in storage unit conversions utilty in Java?

Hi, there doesn't seem to be an existing util class for converting a storage unit from one to another in Java, am I right? Or is there one actually I wasn't aware of? What I was looking for is something like java.util.concurrent.TimeUnit utility. I can implement the equivalent for storage unit by myself, but just thought I would ask f...

Impact of email verification hurdle on rate of acquiring new users

Hi, I'm considering to add "hard" email verification to my website(s). I.e. require users visit a link with a verification key sent by email before they can post content. This will add an extra step in the registration procedure and I'm concerned that it may keep some users away. In practice how does this affect the rate of new people...

Convert a single hex character to its byte value in java

I have a single hexadecimal character, say char c = 'A'; What's the proper way of converting that to its integer value int value =??; assert(a == 10); Doesn't matter really for now if a is an int or a byte. ...

does python have conversion operators?

I don't think so, but I thought I'd ask just in case. For example, for use in a class that encapsulates an int: i = IntContainer(3) i + 5 And I'm not just interested in this int example, I was looking for something clean and general, not overriding every int and string method. Thanks, sunqiang. That's just what I wanted. I didn't ...