 |
| C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

June 23rd, 2004, 07:27 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 996
Thanks: 2
Thanked 11 Times in 11 Posts
|
|
simple C++ functions
Hi there:
I have a simple but urgent problem:
there was a soem functions in C++ to return number of Characher
What is it in C#?!
ie: in Delphi is like:
Code:
Ord("A") --> 65
Chr(65) --> "A"
Can any1 help me, Im changing a written function from Delphi to C# but I dont know the functions.
Always:),
Hovik Melkomian.
__________________
Always,
Hovik Melkomian.
|
|

June 23rd, 2004, 12:56 PM
|
|
|
try:
char symbol = (char)65;
|
|

June 23rd, 2004, 01:10 PM
|
|
|
I think that I got it wrong: to convert from character to integer try:
int number = Char.Parse("A");
|
|

June 26th, 2004, 01:04 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 996
Thanks: 2
Thanked 11 Times in 11 Posts
|
|
Tnx for response dear: I got it. but I still have problem with that.
Its ok when I do it for English Characters. (a-z)
But since my program is in Farsi (Arabic & Right-to-Left) Then I wanan get its Ascci Number it gives me Unicode Number.
A key in Farsi keybord is à (Unicode=1588)
& it gives me 1588 on (int)'Ã'
Do u have any solution for that?!Its really urgent...
Always:),
Hovik Melkomian.
|
|

June 27th, 2004, 08:23 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 996
Thanks: 2
Thanked 11 Times in 11 Posts
|
|
Ok I guess I HAVE TO write a function for it. to cinvert from Unicode to Ascci Codes.
NO COMMENT?!
Always:),
Hovik Melkomian.
|
|

June 30th, 2004, 11:01 AM
|
|
Authorized User
|
|
Join Date: Jun 2004
Posts: 39
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Does getch() work ?
|
|

July 14th, 2004, 03:15 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 996
Thanks: 2
Thanked 11 Times in 11 Posts
|
|
Dear all:
I tried:
Code:
Encoding enc = Encoding.GetEncoding(1256);
byte[] buffer = enc.GetBytes("MyString");
to get ASCII vales of my MyString, & its perfect.
Now I need something more, to converto that CharactersFrom ASCII to Code-page 1256.
I tryed:
Code:
byte[] asciiBytes = {211};
byte[] unicodeBytes = Encoding.Convert(Encoding.ASCII, Encoding.GetEncoding(1256), asciiBytes);
But it doesnt work.
Do I miss anything or Im completely in wrong way.
Any help is appreciated.
Always:),
Hovik Melkomian.
|
|

July 16th, 2004, 12:53 AM
|
|
Registered User
|
|
Join Date: Jun 2004
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi melvik
Have you solved your problem?
melvik I think you have to use Unicide charset in your .NET application
if you want to use CHAR variables because in .NET,the declaration of char variables
is according to the unicode ...
Melvik..I think ASCII code is in a range between 0 to 255
therefore a letter like 'Ã' with 1588(0634 in hexa)can not be an ASCII code(you know it is UNICODE)
but here for example the code for 'A' is 65(0041 in hexa)
(please go to Character Map)
I think mainly Farsi letters don't use ASCII code.
for example in DOS period(!!!)when I changed my default language to Farsi when I pressed A,'Ã' printed in my screen ,there,the code for 'Ã' was 65 just like 'A'(in ASCII)
the method behind it was only changing the shape of 'A' to 'Ã' in the memory when your default language is Farsi.
I think anyway yo have to use UNICODE in your .NET application due to the declaration of CHAR vriables in .NET....
for example
string myString="Melvik";
//convert your strig to a char array
char[] letters=myString.ToCharArray();
//then use this array for getting your letters
//here letter[0] is 'M'
then convert them(with System.Convert())to evry type you want..
Did it help you?...
|
|

July 17th, 2004, 01:00 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 996
Thanks: 2
Thanked 11 Times in 11 Posts
|
|
Dear Mahdi: Tnx for ur response & Happy to see an Iranian here too!
u r right but who told I use ASCII in my app?! Im not that much free to change & make new method:D I know .NET use Unicode for it all texts bc of Multi language support!
The sory of using ASCII is:
My Org. Use a encrypted Password for users & I should do it in my App too! (since all users have already have encrypted password in DB & the same users should use my App too!)
this encryption function use the ASCII of Characters. All softwares in Org has made in Delphi & they only use [u]Ord()</u>(Char to int) & [u]Chr()</u>(int to Char) functions of Delphi witch the values are as same as we had in DOS (as u know) but I cant do it here.
By now I could able to simulate [u]Ord()</u> function in .NET but still have problem in simulating [u]Chr()</u> function!
All App had done & I just stopped here to release that.
Always:),
Hovik Melkomian.
|
|

July 17th, 2004, 03:10 AM
|
|
Friend of Wrox
|
|
Join Date: Jul 2004
Posts: 623
Thanks: 0
Thanked 1 Time in 1 Post
|
|
I changed my ID to mehdi62b
>>Dear Mahdi: Tnx for ur response & Happy to see an Iranian here too!
Especial for Melvik
"øÃÃãÃÃÃ:ãä æÃÃÃà áÃà ãà ÃÃã ÃÃä Ãææäà Ãæ ãà ÃÃäã ãÃÃÃä Ãæ ÃÃæãÃà ÃÃËÃ"
:D:D:D
Melvik,I don't know how you simulated Ord() but I think if you go to Character Map
you can simulate Chr()
for example(all numbers are hexa)
'Ã'---->UNICODE(0634)------->'a'------->ASCII(61)
'Ã'---->UNICODE(0628)------->'f'------->ASCII(66)
'ã'---->UNICODE(0645)------->'l'------->ASCII(6c)
or even digits
'#1636;'---->UNICODE(0664)------->'4'------->ASCII(34)
//1636 is decimal of 0664
'#1638;'---->UNICODE(0666)------->'6'------->ASCII(36)
.
.
.
Then you should make a relation between these two kinds of numbers
(I mean for ASCII and UNICODE)
for example for 'Ã' you should convert 0634(UNICODE) to 61(ASCII)that simulates Ord()
and inverse convertion simulates Chr()(all the numbers are hexa)
now for convertion you can use twenty four Case clauses and...
-----------------------------------
Chr() simulation
switch(Password)
{
case 61://for convertion 61(ASCI code for 'Ã') to 0634(UNICODE for 'a')
UNICODEResult=0634;
break;
.
.
.
--------------------------------
Then you can use UNICODEResult for getting the corresponding letter
in this methos you only deal with numbers(Password and UNICODEResult are integer)
Please go on this and Tell me your results
-----------------------------------
Mahdi
I'm waiting for your better idea.
|
Similar Threads
|
| Thread |
Thread Starter |
Forum |
Replies |
Last Post |
| C functions...??? |
ethantinder |
C# |
2 |
April 25th, 2008 02:25 AM |
| Functions |
LTello |
BOOK: Professional JavaScript for Web Developers ISBN: 978-0-7645-7908-0 |
3 |
September 15th, 2006 11:15 AM |
| functions |
xelepi |
PHP How-To |
1 |
March 10th, 2006 02:59 AM |
| Help with Functions |
megabytes |
C# |
1 |
August 7th, 2003 12:48 PM |
|
 |