conversion

C# dynamic type conversions

Hi Guys, We have 2 objects A & B: A is system.string and B is some .net primitive type (string,int etc). we want to write generic code to assign the converted (parsed) value of B into A. Any suggestions? Thanks, Adi Barda ...

Is there a good way to use Console.ReadKey for choosing between values without doing alot of conversion between types?

Im using Console.ReadKey() to choose from a number of options that varies from time to time. Before this initial code snippet there is a for loop that counts occurances into counter variable of type int. The point is to use Console.ReadKey() to get an int. int choice = ReadKey(); Console.WriteLine(""); if (choice < counter) { mail...

What is the most efficient way to convert an int to a String?

Say I have: int someValue = 42; Now I want to convert that int value to a String. Which way is more efficient? // One String stringValue = Integer.toString(someValue); // Two String stringValue = String.valueOf(someValue); // Three String stringValue = someValue + ""; I am just curious if there is any real difference or one is be...

Converting decimals to sexagesimal (base sixty) in javascript

What is the best way to convert decimal numbers (base ten) to sexagesimal (base sixty) represented as a string using 0-9, A-Z and a-x as the digits. I'm planning to code it in javascript but any help is appreciated. Usage Example: >>decToSex(60); "10" >>decToSex(123); "23" >>decToSex(1000000); "4bke" >>decToSex(1234567.89); "5gu7.rO" ...

wrong argument conversion preferred when calling function

I'm writing a program under MS Visual C++ 6.0 (yes, I know it's ancient, no there's nothing I can do to upgrade). I'm seeing some behavior that I think is really weird. I have a class with two constructors defined like this: class MyClass { public: explicit MyClass(bool bAbsolute = true, bool bLocation = false) : m_bAbsolute(bAbso...

Converting PCL to PDF

I am looking to create (as a proof-of-concept) an OCaml (preferably) program that converts PCL code to PDF format. I am not sure where to start. Is there a standardized algorithm for doing so? Is there any other advice available for accomplishing this task? Thanks! ...

Convert a RTF document to Image or print RTF on server

I have a situation where I want to convert a RTF document to image for archiving and printing. I am using .NET. Are there any libraries out there that could help me with this conversion? I need to convert a RTF to image on a server set the paper size that needs to be adhered to when creating the image A commercial library is an op...

Is there an elegant way to convert ISO 639-2 (3 letter) language codes to Java Locales?

E.g. eng, spa, ita, ger I could iterate all locales and compare the codes, but I wonder whether there is a more elegant & performant way to achieve this.... Thanks a lot for any hints :) ...

Passing C# data type parameters to dll written in C++?

Still working on a problem that started from here Calling C++ dll function from C#: Of structs, strings and wchar_t arrays., but with a different approach. Following the example Calling Managed Code from Unmanaged Code and vice-versa I wrote a managed wrapper in C++ to access the unmanages class in the unmanaged C++ dll. It looks like ...

What is the best way to convert a hexidecimal string to a byte array (.NET)?

I have a hexidecimal string that I need to convert to a byte array. The best way (ie efficient and least code) is: string hexstr = "683A2134"; byte[] bytes = new byte[hexstr.Length/2]; for(int x = 0; x < bytes.Length; x++) { bytes[x] = Convert.ToByte(hexstr.Substring(x * 2, 2), 16); } In the case where I have a 32bit value I can d...

Converting RGB to grayscale/intensity

When converting from RGB to grayscale, it is said that specific weights to channels R, G, and B ought to be applied. These weights are: 0.2989, 0.5870, 0.1140. It is said that the reason for this is different human perception/sensibility towards these three colors. Sometimes it is also said these are the values used to compute NTSC sign...

SQL Server 2008 Converting VARCHAR(50) to Uniqueidentifier

Hi! I'm trying to convert a varchar(50) column to a uniqueidentifier, but this error keeps popping up all the time, and i don't know why: "Msg 8169, Level 16, State 2, Line 1 Conversion failed when converting from a character string to uniqueidentifier." The data in the column is currently a valid uniqueidentifier. What's the proper...

C# Problem using blowfish NET: How to convert from Uint32[] to byte[]

Hello, In C#,I'm using Blowfish.NET 2.1.3's BlowfishECB.cs file(can be found here) In C++,It's unknown,but it is similiar. In C++,the Initialize(blowfish) procedure is the following: void cBlowFish::Initialize(BYTE key[], int keybytes) In C#,the Initialize(blowfish) procedure is the same public void Initialize(byte[] key, int ofs,...

Bitmask to Array Index

Hello, Is there a simple way to convert a bitmask in to an array index? ie. If i've got an enum a = 0x01, b = 0x02, c = 0x04, d = 0x08, e = 0x10, etc and I want to store releated data in an array, is there a simple way such that i can convert a to 0, b to 1, c to 2. etc? Many thanks ...

Conditionally branching in SQL based on the type of a variable.

Hi everyone. I'm selecting a value out of a table that can either be an integer or a nvarchar. It's stored as nvarchar. I want to conditionally call a function that will convert this value if it is an integer (that is, if it can be converted into an integer), otherwise I want to select the nvarchar with no conversion. This is hitti...

Display the binary representation of a number in C?

Still learning C and I was wondering: Given a number, is it possible to do something like the following? char a = 5; printf("binary representation of a = %b",a); > 101 Or would i have to write my own method to do the transformation to binary? ...

Looking how to Implement Document Conversion in MOSS 2007

We've been tasked with creating a MOSS workflow that on it's final step will convert a document (most likely from word 2003 or 2007) to PDF and watermark it with the current date. So far I haven't seen a definitive way to do this. Have looked at using the MS Word Interop dlls, but we will not be installing Word (or Office) onto the ser...

SQL Query convert integer to hex and hex to integer

So I have this Query working (where signal_data is a column) in Sybase but it will not work with Microsoft SQL Server: HEXTOINT(SUBSTRING((INTTOHEX(signal_data)),5,2)) as Signal I also have it in Excel (where A1 contains the value): =HEX2DEC(LEFT(DEC2HEX(A1),LEN(DEC2HEX(A1))-2)) Does anyone know how I would do this in SQL? ...

Control events not firing after ASP.NET 3.5 conversion

My department is currently converting all of our projects from 2.0 to 3.5, and we are experiencing an odd side effect. It seems that most, if not all, control events aren't firing after we convert the projects to the 3.5 framework. At least not initially. Case in point, I was looking at one of our internal interfaces that had been con...

How can a text file be converted from ANSI to UTF-8 with Delphi 7?

I written a program with Delphi 7 which searches *.srt files on a hard drive. This program lists the path and name of these files in a memo. Now I need convert these files from ANSI to UTF-8, but I haven't succeeded. Please help me... ...