working witg UCS4Char

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

working witg UCS4Char

ik-6
Hello,

I'm trying to work with UCS4Char (for this:
https://github.com/ik5/fp-msgpack), but I can't figure out how to do
it.
For example, if do the following:

-------------------------------
{$H+}
uses cwstring;

var
 ch : UCS4Char;

begin
  ch := #$233B4;
  writeln(ch);
end.
-------------------------------

I get the following error:
ppcx64 test.pas
Free Pascal Compiler version 2.6.0 [2012/05/17] for x86_64
Copyright (c) 1993-2011 by Florian Klaempfl and others
Target OS: Linux for x86-64
Compiling test.pas
test.pas(8,9) Error: Illegal char constant
test.pas(8,9) Error: Incompatible types: got "Constant String"
expected "UCS4Char"
test.pas(11) Fatal: There were 2 errors compiling module, stopping
Fatal: Compilation aborted


And if I do it without the hash, then it's just a number

So how can I use it ?

Thanks,
Ido
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: working witg UCS4Char

Jonas Maebe-2

On 09 Nov 2012, at 16:06, ik wrote:

And if I do it without the hash, then it's just a number

UCS4Char is in fact just a number, and UCS4String is just a dynamic array of cardinal. UCS4 is not implemented as a complete string type in FPC (or Delphi, for that matter).


Jonas

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: working witg UCS4Char

ik-6
On Fri, Nov 9, 2012 at 5:16 PM, Jonas Maebe <[hidden email]> wrote:
>
> On 09 Nov 2012, at 16:06, ik wrote:
>
> And if I do it without the hash, then it's just a number
>
>
> UCS4Char is in fact just a number, and UCS4String is just a dynamic array of
> cardinal. UCS4 is not implemented as a complete string type in FPC (or
> Delphi, for that matter).

Cardinal is a bit problematic type, you mean longword. :)

Thanks

>
>
> Jonas
>
> _______________________________________________
> fpc-pascal maillist  -  [hidden email]
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: working witg UCS4Char

Tomas Hajny-2
On Fri, November 9, 2012 17:01, ik wrote:

> On Fri, Nov 9, 2012 at 5:16 PM, Jonas Maebe <[hidden email]>
> wrote:
>> On 09 Nov 2012, at 16:06, ik wrote:
>>
>> And if I do it without the hash, then it's just a number
>>
>>
>> UCS4Char is in fact just a number, and UCS4String is just a dynamic
>> array of
>> cardinal. UCS4 is not implemented as a complete string type in FPC (or
>> Delphi, for that matter).
>
> Cardinal is a bit problematic type, you mean longword. :)

Why do you see cardinal as a "problematic type"? At least for FPC it is a
simple alias to longword (and it has actually existed even before longword
in FPC).

Tomas


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: working witg UCS4Char

ik-6
On Fri, Nov 9, 2012 at 6:12 PM, Tomas Hajny <[hidden email]> wrote:

> On Fri, November 9, 2012 17:01, ik wrote:
>> On Fri, Nov 9, 2012 at 5:16 PM, Jonas Maebe <[hidden email]>
>> wrote:
>>> On 09 Nov 2012, at 16:06, ik wrote:
>>>
>>> And if I do it without the hash, then it's just a number
>>>
>>>
>>> UCS4Char is in fact just a number, and UCS4String is just a dynamic
>>> array of
>>> cardinal. UCS4 is not implemented as a complete string type in FPC (or
>>> Delphi, for that matter).
>>
>> Cardinal is a bit problematic type, you mean longword. :)
>
> Why do you see cardinal as a "problematic type"? At least for FPC it is a
> simple alias to longword (and it has actually existed even before longword
> in FPC).

At least with Delphi it has unclear what exactly the size of it.
And the following code:
https://github.com/ik5/fp-msgpack/blob/master/src/msgpack.pas#L528

Used to be with Cardinal (the only difference), and It never acted as expected.
The only thing I changed was from cardinal to longword, and it acts as expected.

>
> Tomas
>
>
> _______________________________________________
> fpc-pascal maillist  -  [hidden email]
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: working witg UCS4Char

Tomas Hajny-2
On Fri, November 9, 2012 17:38, ik wrote:

> On Fri, Nov 9, 2012 at 6:12 PM, Tomas Hajny <[hidden email]> wrote:
>> On Fri, November 9, 2012 17:01, ik wrote:
>>> On Fri, Nov 9, 2012 at 5:16 PM, Jonas Maebe <[hidden email]>
>>> wrote:
>>>> On 09 Nov 2012, at 16:06, ik wrote:
>>>>
>>>> And if I do it without the hash, then it's just a number
>>>>
>>>>
>>>> UCS4Char is in fact just a number, and UCS4String is just a dynamic
>>>> array of
>>>> cardinal. UCS4 is not implemented as a complete string type in FPC (or
>>>> Delphi, for that matter).
>>>
>>> Cardinal is a bit problematic type, you mean longword. :)
>>
>> Why do you see cardinal as a "problematic type"? At least for FPC it is
>> a
>> simple alias to longword (and it has actually existed even before
>> longword
>> in FPC).
>
> At least with Delphi it has unclear what exactly the size of it.
> And the following code:
> https://github.com/ik5/fp-msgpack/blob/master/src/msgpack.pas#L528
>
> Used to be with Cardinal (the only difference), and It never acted as
> expected.
> The only thing I changed was from cardinal to longword, and it acts as
> expected.

With Delphi or with FPC? As already mentioned, FPC defines cardinal as an
alias to longword (and UInt32 mentioned in your reference as an alias to
cardinal) so there should be no difference between cardinal, longword and
UInt32 (and in the past, cardinal was even the primary type in FPC
directly known by the compiler).

With Delphi, I believe that very old Delphi versions defined cardinal as a
31-bit type (i.e. simply the non-negative part of the longint range), but
I also believe (while not using Delphi at all myself) that all currently
relevant Delphi versions (i.e. not considering things like Delphi 1.0 and
Delphi 2.0 which probably didn't support longword anyway) define cardinal
as equal to longword.

Tomas


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: working witg UCS4Char

ik-6
On Fri, Nov 9, 2012 at 6:56 PM, Tomas Hajny <[hidden email]> wrote:

> On Fri, November 9, 2012 17:38, ik wrote:
>> On Fri, Nov 9, 2012 at 6:12 PM, Tomas Hajny <[hidden email]> wrote:
>>> On Fri, November 9, 2012 17:01, ik wrote:
>>>> On Fri, Nov 9, 2012 at 5:16 PM, Jonas Maebe <[hidden email]>
>>>> wrote:
>>>>> On 09 Nov 2012, at 16:06, ik wrote:
>>>>>
>>>>> And if I do it without the hash, then it's just a number
>>>>>
>>>>>
>>>>> UCS4Char is in fact just a number, and UCS4String is just a dynamic
>>>>> array of
>>>>> cardinal. UCS4 is not implemented as a complete string type in FPC (or
>>>>> Delphi, for that matter).
>>>>
>>>> Cardinal is a bit problematic type, you mean longword. :)
>>>
>>> Why do you see cardinal as a "problematic type"? At least for FPC it is
>>> a
>>> simple alias to longword (and it has actually existed even before
>>> longword
>>> in FPC).
>>
>> At least with Delphi it has unclear what exactly the size of it.
>> And the following code:
>> https://github.com/ik5/fp-msgpack/blob/master/src/msgpack.pas#L528
>>
>> Used to be with Cardinal (the only difference), and It never acted as
>> expected.
>> The only thing I changed was from cardinal to longword, and it acts as
>> expected.
>
> With Delphi or with FPC? As already mentioned, FPC defines cardinal as an
> alias to longword (and UInt32 mentioned in your reference as an alias to
> cardinal) so there should be no difference between cardinal, longword and
> UInt32 (and in the past, cardinal was even the primary type in FPC
> directly known by the compiler).
>
> With Delphi, I believe that very old Delphi versions defined cardinal as a
> 31-bit type (i.e. simply the non-negative part of the longint range), but
> I also believe (while not using Delphi at all myself) that all currently
> relevant Delphi versions (i.e. not considering things like Delphi 1.0 and
> Delphi 2.0 which probably didn't support longword anyway) define cardinal
> as equal to longword.

With FPC. The value was saved wrong.
The only thing that I changed in my code was moving from Cardinal to LongWord.

I do not own Delphi or Windows copy for many years now :)

>
> Tomas
>
>
> _______________________________________________
> fpc-pascal maillist  -  [hidden email]
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: working witg UCS4Char

Tomas Hajny-2
On 10 Nov 12, at 0:28, ik wrote:
> On Fri, Nov 9, 2012 at 6:56 PM, Tomas Hajny <[hidden email]> wrote:
> > On Fri, November 9, 2012 17:38, ik wrote:
> >> On Fri, Nov 9, 2012 at 6:12 PM, Tomas Hajny <[hidden email]> wrote:
> >>> On Fri, November 9, 2012 17:01, ik wrote:
 .
 .

> >>>> Cardinal is a bit problematic type, you mean longword. :)
> >>>
> >>> Why do you see cardinal as a "problematic type"? At least for FPC it is
> >>> a
> >>> simple alias to longword (and it has actually existed even before
> >>> longword
> >>> in FPC).
> >>
> >> At least with Delphi it has unclear what exactly the size of it.
> >> And the following code:
> >> https://github.com/ik5/fp-msgpack/blob/master/src/msgpack.pas#L528
> >>
> >> Used to be with Cardinal (the only difference), and It never acted as
> >> expected.
> >> The only thing I changed was from cardinal to longword, and it acts as
> >> expected.
> >
> > With Delphi or with FPC? As already mentioned, FPC defines cardinal as an
> > alias to longword (and UInt32 mentioned in your reference as an alias to
> > cardinal) so there should be no difference between cardinal, longword and
> > UInt32 (and in the past, cardinal was even the primary type in FPC
> > directly known by the compiler).
 .
 .
> With FPC. The value was saved wrong.
> The only thing that I changed in my code was moving from Cardinal to LongWord.
 .
 .

Sorry, but I cannot imagine how this could happen considering that
one of them is alias to the other and thus they cannot be treated
differently by the compiler (you can even interchange them for actual
parameters and the compiler wouldn't notice it). If you have a short
test showing otherwise, please post a bug report.

Tomas

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: working witg UCS4Char

valeray12
This post has NOT been accepted by the mailing list yet.
In reply to this post by ik-6
How much do colleges (UCs) care about your AP exam scores?
[url=http://www.barstoolmegastore.com]bar stool[/url]