AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

Project from Ansi to Unicode

Ein Thema von WojTec · begonnen am 8. Apr 2014 · letzter Beitrag vom 10. Apr 2014
Antwort Antwort
WojTec

Registriert seit: 17. Mai 2007
480 Beiträge
 
Delphi XE6 Professional
 
#1

Project from Ansi to Unicode

  Alt 8. Apr 2014, 16:06
Delphi-Version: 2010
I found nice unit to work with torrents:

Code:
http://torrentspy.cvs.sourceforge.net/viewvc/torrentspy/TorrentSpy-0.2-delphi/src/
So, TorrentFile.pas and included ones are not Unicode ready. I can't make it working with D2010+ (I only can exchange MessageDigests.pas with DEC). Could you help, please?

Delphi-Quellcode:
// Test code: Ansi - oke, Unicode - empty

var
  T: TTorrentFile;
  F: TStream;
begin
  if OpenDialog1.Execute then
  begin
    T := TTorrentFile.Create;
    F := TFileStream.Create(OpenDialog1.FileName, fmOpenRead);
    try
      T.Load(F);
      ShowMessage(T.Announce + #13#10 + T.CreatedBy + #13#10 + T.CreationDateAsString);
    finally
      T.Free;
      F.Free;
    end;
  end;
end;
  Mit Zitat antworten Zitat
Benutzerbild von jaenicke
jaenicke

Registriert seit: 10. Jun 2003
Ort: Berlin
9.332 Beiträge
 
Delphi 11 Alexandria
 
#2

AW: Project from Ansi to Unicode

  Alt 8. Apr 2014, 19:35
After a quick look I think you just have to replace String with AnsiString and PChar with PAnsiChar inside the unit.
Sebastian Jänicke
Alle eigenen Projekte sind eingestellt, ebenso meine Homepage, Downloadlinks usw. im Forum bleiben aktiv!
  Mit Zitat antworten Zitat
WojTec

Registriert seit: 17. Mai 2007
480 Beiträge
 
Delphi XE6 Professional
 
#3

Re: Project from Ansi to Unicode

  Alt 9. Apr 2014, 19:02
So, I made some modifications, result attached, but don't working as expected, eg. name is empty or length is zero or wrong hash, but announce or agent are good. Same project on Ansi compiler is oke
Angehängte Dateien
Dateityp: 7z torrentfileunicode_bad.7z (18,3 KB, 9x aufgerufen)

Geändert von WojTec ( 9. Apr 2014 um 19:16 Uhr) Grund: More info
  Mit Zitat antworten Zitat
Benutzerbild von jaenicke
jaenicke

Registriert seit: 10. Jun 2003
Ort: Berlin
9.332 Beiträge
 
Delphi 11 Alexandria
 
#4

AW: Project from Ansi to Unicode

  Alt 9. Apr 2014, 20:20
You forgot to exchange Char with AnsiChar in unit BCode. If I do so it works.
Sebastian Jänicke
Alle eigenen Projekte sind eingestellt, ebenso meine Homepage, Downloadlinks usw. im Forum bleiben aktiv!
  Mit Zitat antworten Zitat
WojTec

Registriert seit: 17. Mai 2007
480 Beiträge
 
Delphi XE6 Professional
 
#5

Re: Project from Ansi to Unicode

  Alt 10. Apr 2014, 09:26
Yap, I forgot Thank you, now working

But now there is next problem, because can use Unicode in file names and unit is Ansi, can't read Unicode names. I saw maybe 2 times Unicode torrents, but it is possible. How to enable support for Unicode strings inside?

Here Torrent_file#File_structure is information that strings are Unicode at all. Now I don't understand, why Ansi is working, but Unicode is not working

Geändert von WojTec (10. Apr 2014 um 09:50 Uhr) Grund: Something more
  Mit Zitat antworten Zitat
Benutzerbild von jaenicke
jaenicke

Registriert seit: 10. Jun 2003
Ort: Berlin
9.332 Beiträge
 
Delphi 11 Alexandria
 
#6

AW: Project from Ansi to Unicode

  Alt 10. Apr 2014, 14:26
You find the answer in your own link:
Zitat:
All strings must be UTF-8 encoded.
Perhaps it already works, if you use UTF8String instead of AnsiString, but perhaps you have to decode the UTF-8 format explicitly or perhaps it has to be read differently (I did not have a look now). Delphi uses UTF-16, so it does not understand UTF-8, if you don't tell it to read something as UTF-8.
Sebastian Jänicke
Alle eigenen Projekte sind eingestellt, ebenso meine Homepage, Downloadlinks usw. im Forum bleiben aktiv!
  Mit Zitat antworten Zitat
WojTec

Registriert seit: 17. Mai 2007
480 Beiträge
 
Delphi XE6 Professional
 
#7

Re: Project from Ansi to Unicode

  Alt 10. Apr 2014, 16:49
Exchange type Ansi to UTF8 is working, but what with PAnsiChar typecast and AnsiChar (working, but there is no additional UTF8 routines required?)?
  Mit Zitat antworten Zitat
WojTec

Registriert seit: 17. Mai 2007
480 Beiträge
 
Delphi XE6 Professional
 
#8

Re: Project from Ansi to Unicode

  Alt 10. Apr 2014, 17:41
Also another question: has Delphi build-in routines to replace Hashes.pas unit?
  Mit Zitat antworten Zitat
Antwort Antwort


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 08:31 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz