Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / dbChr not returning correct characters???

Author
Message
old man
20
Years of Service
User Offline
Joined: 25th Feb 2004
Location:
Posted: 22nd Nov 2008 15:51
Hello

I am trying to use dbChr(247) to show a divide sign.

This works fine in DBP with any english language font, but does not work in dark GDK in c++. I get a different result depending upon the font!

I have tried different fonts and I get the correct symbol with system, but of course system is a very poor font to use and I want to use Arial or Comic Sans MS, anything but System!

Any ideas / solutions?

uff
prasoc
16
Years of Service
User Offline
Joined: 8th Oct 2008
Location:
Posted: 22nd Nov 2008 16:02
dbSetTextFont("Arial");
old man
20
Years of Service
User Offline
Joined: 25th Feb 2004
Location:
Posted: 22nd Nov 2008 16:14
Yes Prosac, I understand that is how to set the font, my question is about why dbChr(247) does not return a divide sign.

uff
prasoc
16
Years of Service
User Offline
Joined: 8th Oct 2008
Location:
Posted: 22nd Nov 2008 16:18
you could use "char divide = 247;" which would be a divide sign. C++ doesn't really have a chr() function, and I don't really know why dbChr() wouldn't work...
old man
20
Years of Service
User Offline
Joined: 25th Feb 2004
Location:
Posted: 22nd Nov 2008 16:35
How would I use "char divide = 247;"??

I want to print the character. In DBP I would
Print chr$(247)

in GDK
dbPrint(dbChr(247));

that does not work so what would be the code in c++?

uff
SunDawg
19
Years of Service
User Offline
Joined: 21st Dec 2004
Location: Massachusetts
Posted: 22nd Nov 2008 16:42 Edited at: 22nd Nov 2008 16:43
That only works for the font 'arial,' because other fonts aren't arranged the same way. I don't know what you're talking about with DBPro, because when I tried it, the default font returned a capital R for character 247.




My site, for various stuff that I make.
old man
20
Years of Service
User Offline
Joined: 25th Feb 2004
Location:
Posted: 22nd Nov 2008 16:52
Thanks SunDawg

Yes, with the default font, (whatever that is), I get the same, but if I set the font to Arial, Comic Sans MS, Times New Roman etc. I get the divide sign in DBP but not in GDK.

uff
Lilith
16
Years of Service
User Offline
Joined: 12th Feb 2008
Location: Dallas, TX
Posted: 23rd Nov 2008 00:25
Quote: "Stupid question maybe, but why can't you just type in the divide sign?"


Because extended ASCII characters aren't on the keyboard. Extended ASCII defines 247 and the "approximately equals" (stacked tildes) symbol.

One thing you might want to keep in mind is that you're using a signed character. You might try declaring divide as an unsigned character.

Lilith, Night Butterfly
I'm not a programmer but I play one in the office
sydbod
16
Years of Service
User Offline
Joined: 14th Jun 2008
Location: Just look at the picture
Posted: 23rd Nov 2008 01:30
There are always easier ways of doing things. Just create the character that you want in the text string itself. This way one can see the results directly without any fancy program code required.

If a person is using "Arial".

Here is its character map: http://www.htmlguide.us/maparial.shtml

We see that " ÷ " has a keyboard character code of "0247".

In the text at the place where you want that character to show up

do the following.

Hold down the "Alt" key.
On the Num Pad press the numbers one after the other "0" "2" "4" "7" , and then release the "Alt" key.

You should now see the " ÷ " character appear in the text string.
old man
20
Years of Service
User Offline
Joined: 25th Feb 2004
Location:
Posted: 23rd Nov 2008 11:42
Thanks for all that, but I still have the problem.
SidBods method of showing the divide sign certainly works in the C++ code window so I tried:
dbPrint("÷") and the run gave me a downshifted F
dbPrint(dbChr(0247)) gave me a "double S" thing that I do not recognise as a character.
dbPrint(dbChr(247)) gave me a downshifted F

My knowledge of C++ is almost zero but I did try puts("÷") etc but got absolutely nothing, not even a new line!, also tried
puts("Hello") as described in C++ Beginers Guide but again nothing.

I can always revert to / but some people do not see that as divide. I think there must be a way that someone can come up with!? .

uff
pcRaider
17
Years of Service
User Offline
Joined: 30th May 2007
Location:
Posted: 23rd Nov 2008 12:37
try this

old man
20
Years of Service
User Offline
Joined: 25th Feb 2004
Location:
Posted: 23rd Nov 2008 13:11
Thanks everybody, especially pcRaider who has given the solution.

I just changed SetFont("Arial") to SetFont("Arial",1) and problem solved. I would never have got there without him!

Nice to have a post that comes up with a simple solution in the end.

Thanks again!!

uff
Benjamin
22
Years of Service
User Offline
Joined: 24th Nov 2002
Location: France
Posted: 23rd Nov 2008 15:31 Edited at: 23rd Nov 2008 15:36
Quote: ""char" is always unsigned. At least in every version of C++ I've ever seen."

Strange, I've never known it to be like that. If you try assigning a value higher than 127 to a char in VC++, you will get a compiler warning. Besides, this demonstrates that it is signed:



IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 23rd Nov 2008 21:35 Edited at: 23rd Nov 2008 21:47
The signed-ness of char is implementation defined - I've known it to go either way.

In this case, Visual C++, char is signed, unless you switch it (Configuration Properties -> C++ -> Language -> Default Char Unsigned).

This code demonstrates that the value 250, when assigned to a char is converted to -6 (2's complement of the unsigned value 250 in 8 bits):


[EDIT]
Actually, to be clear, a char is not the same as a signed char in VC++ - they are two distinct types that just happen to have similar characteristics. You can test this by making 3 overloaded functions accepting char, signed char and unsigned char:


Benjamin
22
Years of Service
User Offline
Joined: 24th Nov 2002
Location: France
Posted: 24th Nov 2008 01:22
Quote: "No, it doesn't."

Does.

Login to post a reply

Server time is: 2024-11-25 07:50:30
Your offset time is: 2024-11-25 07:50:30