Recent

Author Topic: parsing widechar string  (Read 2826 times)

alexeyneu

  • Newbie
  • Posts: 2
parsing widechar string
« on: March 08, 2021, 03:57:32 pm »
so i've need to grab a value from '198.45 ₽' .
that's how it's done 
Code: [Select]
const s1 = 'äй';
const s2: string = #$C3#$A4; // ä
var s3;
...
  s3 := 'äöü';
...

And that's how it's really done
Code: [Select]
uses crt , cwstring;

Var
        cargo , xload : Currency;
f : WideString;
e , w , k , load , miles , run  : Integer;
begin
ReadLn(f);
Val(f , cargo , e);
if (e <> 0) and (Pos('₽',f) <> 0) then
begin
Delete(f , length(f) - 2, 7);
Val(f , cargo , e);
end;
Writeln(cargo:3:2);
end.


 

Bart

  • Hero Member
  • *****
  • Posts: 4225
    • Bart en Mariska's Webstek
Re: parsing widechar string
« Reply #1 on: March 08, 2021, 10:24:22 pm »
And the question is?

Bart

alexeyneu

  • Newbie
  • Posts: 2
Re: parsing widechar string
« Reply #2 on: March 09, 2021, 02:40:20 am »
you have zero info on that .  cwstring promoted as a windows system stuff . of those two codeblocks first one is yours
« Last Edit: March 09, 2021, 08:39:36 am by alexeyneu »

Bart

  • Hero Member
  • *****
  • Posts: 4225
    • Bart en Mariska's Webstek
Re: parsing widechar string
« Reply #3 on: March 09, 2021, 03:13:18 pm »
you have zero info on that .

I asked you if you had a quesion about the code or problem you posted.
This part of your respons makes absolutley no sense to me at all in that context.

  cwstring promoted as a windows system stuff

Unit cwstring is needed as widestring manager under *nix.

of those two codeblocks first one is yours

I beg your pardon?

Bart

engkin

  • Hero Member
  • *****
  • Posts: 2662
Re: parsing widechar string
« Reply #4 on: March 09, 2021, 03:49:09 pm »
Bart, do you feel that you are talking to a machine?

The code is not marked as Pascal, the first example is scraped from the wiki, and there is a space before and after every period. Not to mention the incoherent sentences.

Bart

  • Hero Member
  • *****
  • Posts: 4225
    • Bart en Mariska's Webstek
Re: parsing widechar string
« Reply #5 on: March 09, 2021, 06:11:16 pm »
That (TS being a machine) would be a poor attempt then...

Bart

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1385
  • Former Delphi 1-7, 10.2 User
Re: parsing widechar string
« Reply #6 on: March 09, 2021, 10:44:48 pm »
The first code block - https://wiki.freepascal.org/Unicode_Support_in_Lazarus#String_Literals

I believe the issue is more to do with an English/Russian language barrier -- Alexey might find it more profitable to use the Russian sub-forum.
Lazarus 2.1 r65019 FPC 3.3.1 r49223 macOS 10.14.6 Xcode 11.3.1
Lazarus 2.1 r65019 FPC 3.3.1 r49223 macOS 11.2.3 aarch64 Xcode 12.4
Lazarus 2.1 r61574 FPC 3.3.1 r42318 FreeBSD 12.1 amd64 VMware VM
Lazarus 2.1 r61574 FPC 3.0.4 Ubuntu 20.04 Parallels VM
Lazarus 2.0.10 FPC 3.2.0 Win10 Parallels VM

 

TinyPortal © 2005-2018