Recent

Author Topic: How do you convert a char to a byte?  (Read 21989 times)

molly

  • Hero Member
  • *****
  • Posts: 2330
Re: How do you convert a char to a byte?
« Reply #15 on: June 09, 2016, 04:28:59 pm »
hmz... 5 posts to suggest using {$H+}... definitely not lazy in my book :D

Thaddy

  • Hero Member
  • *****
  • Posts: 19268
  • Glad to be alive.
Re: How do you convert a char to a byte?
« Reply #16 on: June 09, 2016, 05:37:14 pm »
Well, last one, Molly: it is not just {$H+}. It is about a given example being wrong or incomplete given the status of the compiler today and already for some time.
{H+} just selects longstrings, the Ansi variant. It does not select 1 or 2 or more byte encoding.
The least that should be done is document the example code as being only valid for ansi strings and short strings.

Grrr >:D 8-) ::)
objects are fine constructs. You can even initialize them with constructors.

molly

  • Hero Member
  • *****
  • Posts: 2330
Re: How do you convert a char to a byte?
« Reply #17 on: June 09, 2016, 06:59:13 pm »
Hi Thaddy,

I don't believe i disagreed with what you stated. Even stronger, i will state here that you are correct.

However, seeing the level on which topic starter was/is operating, i don't disagree with sam707's remarks either.

The initial question did not seem to hint or implied a request to complicate things with unnecessary subjects such as byte encoding. And yes, your opinion stating otherwise was/is dearly noted.

Do you really expect all (simple) examples to provide warnings like: This code is not re-entrant, not thread safe, will not play avi files, does not support flac, will not cook your cat in the micro wave ? Because that is also what that code is (not) doing, and i believe is what sam707 was also (partial) hinting at.

Or was it just this particular example that got your attention ?

Quote
It is about a given example being wrong or incomplete given the status of the compiler today and already for some time
And a genuine question from my side in return (with no ulterior motives, it just occurred to me and seems to fit the context): it must be tormenting for you to read (if even) the free pascal / lazarus manuals and wiki ?

Pasqualish

  • Jr. Member
  • **
  • Posts: 73
Re: How do you convert a char to a byte?
« Reply #18 on: June 10, 2016, 03:17:16 am »
I think it is a good suggestion to not use a char in this situation - converting between a char and a byte.
« Last Edit: June 10, 2016, 03:19:42 am by Pasqualish »

 

TinyPortal © 2005-2018