将旧的 Delphi 7 代码迁移到 Delphi XE - 真的需要 unicode 吗?

发布于 2024-12-11 13:17:13 字数 219 浏览 0 评论 0原文

我有一个在 Delphi 7 下运行 BDE 的旧应用程序,现在购买了 Delphi XE。我看到很多人说迁移代码的主要问题是更改为unicode。可能还有支持 unicode 的数据库。

但是,我真的必须这样做吗?我可以不只坚持 BDE 和一些“好的旧字符串格式”吗?

我希望能够在这里快速切换到 Delphi Xe,而不需要使用所有新功能等等......

Rgds PM

I have an old application running BDE under Delphi 7, and have now bought Delphi XE. I see a lot of people say the main problem migrating the code is changing to unicode. And possibly a database supporting unicode.

But, do I really have to do this? Can I not just stick to BDE and some "good old string format"?

I am hoping to get away with a quick swap to Delphi Xe here, not necesarily using all new features etc etc....

Rgds PM

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

随风而去 2024-12-18 13:17:13

将数据连接到数据库的数据字段没有更改。 TStringField 仍然具有 AnsiString 类型的 Value 属性,它与旧行为匹配。

当您检查编译器将发出的所有警告时,您可能会毫不费力地完成并保持 BDE 的活动。

除此之外,我建议在可预见的将来用更新的解决方案替换 BDE - 不仅仅是因为 Unicode。

The data fields that connect your data to the database didn't change. A TStringField still has a Value property of type AnsiString, which matches the old behaviour.

When you inspect all the warnings the compiler will spit out, you might come away with little effort and keep the BDE alive.

Besides that I suggest replacing the BDE with a more recent solution in the foreseeable future - not only because of Unicode.

白日梦 2024-12-18 13:17:13

很难避免使用新的 UnicodeString,这就是 string 现在的别名。如果您愿意,您可以使用 AnsiString 编写所有代码,但何必呢?一旦你使用任何重要的库(例如RTL、VCL、第三方),你就在逆流而上。在我看来,如果您确实尝试继续使用 AnsiString,您实际上会让自己的生活变得更加困难。

如果您尝试一下,您应该会发现迁移到新的 Unicode 字符串类型并不是一件大事。绝大多数现有代码将保持不变。

It's pretty hard to avoid using the new UnicodeString which is what string is now aliased to. You can write all your code with AnsiString if you wish, but why bother? As soon as you use any non-trivial library (e.g. RTL, VCL, third-party) you are swimming against the tide. If you do attempt to continue with AnsiString you'll actually make life more difficult for yourself in my view.

If you give it a go you should find that it's not that big a job to move to the new Unicode string type. The vast majority of existing code will work unchanged.

疯了 2024-12-18 13:17:13

我也做了同样的从 D7 到 XE 的转变,这个改变是致命的。我的应用程序和您的应用程序一样包含一个数据库 - 在我的例子中,它是 Interbase 和 Interbase Express 组件,它们是 Delphi 的一部分。我选择转向 Unicode,但这并不美好。

我读过这些论文,但与我的经验相比,它们似乎不完整,甚至在某些观点上可能是不正确的。我认为这些论文是从没有数据库的 Delphi 应用程序的角度编写的。我相信 Interbase Express (Delphi) 和 Interbase 中存在严重错误。我认为 IB 中至少修复了一个错误,Delphi 中至少修复了几个错误 - 如果您迁移到 XE 版本。 (我现在不想考虑再次经历这个)。

我最终在代码中添加了修复程序来帮助 Delphi 摆脱困境。在新闻组和质量控制中,人们告诉我我不明白。最后,将会有一些变化来解决这些问题,所以肯定是某个地方确实存在问题。

该线程中表达的相互冲突的观点表明了与 Unicode 的混淆。在其中一些问题上,即使经历过,我也不知道它会如何运作。但是,我对能否通过它并保留 BDE 持怀疑态度。这很可能存在无法解决且您无法处理的内置问题。您可以检查 QC 中的一些条目以了解一些未解决的问题。

当我的应用程序在 D7 中时,我的 IB 数据库是 ansi。当第一次转换为 Delpi XE 时,它似乎运行正常 - 尽管这只是一个简短的检查。 IB 支持 Unicode,我在那里转换了我的数据。你会/你能用你的数据做到这一点吗?后来我才发现问题所在。我认为任何有意义的 Unicode 转换都意味着您首先将数据存储转换为 Unicode,然后是 Delphi 应用程序。

既然如此,如果您不需要 unicode,为什么还要转向 XE呢?只是为了升级还是有什么你想要完成的事情?我希望这篇长文能有所帮助。

I made the same move from D7 to XE and the change was a killer. My app, like yours includes a database - in my case its Interbase and the Interbase Express components that are part of Delphi. I made the choice to move to Unicode, but it wasn't pretty.

I read the papers, but compared to my experience they seemed incomplete or maybe even incorrect on some points. I think the papers are written from the point of view of a Delphi application with no database. I believe there were critical errors in Interbase Express (Delphi) and in Interbase. I think at least one bug has been fixed in IB and a couple in Delphi - if you move to the XE version. (I don't want to consider going through that again right now).

I wound up adding fixer-uppers in my code to help Delphi out. On the newsgroups and in QC people told me I didn't understand. Well finally, there are changes coming that fix those problems so there must really be issues there someplace.

The conflicting views expressed in this thread indicate the confusion with Unicode. On some of those issues I don't know how it would work, even having gone through it. But, I have doubts about getting through it at all and holding onto the BDE. That could well have built-in issues that will not be fixed, and which you can't deal with. There are some entries in QC you can check to see some of the outstanding issues.

When my application was in D7 my IB database was ansi. When first converted to Delpi XE, it seemed to run ok - although that was only a brief check. IB supports Unicode and I converted my data there. Would you / could you do that with your data? Only after that did I find the problems. I think any meaningful conversion to Unicode means you first convert your data storage to Unicode, then your Delphi app.

So after all that, why are you moving to XE if you don't want unicode? Is it just to upgrade or is there something you are trying to accomplish? I hope this long post helps.

青巷忧颜 2024-12-18 13:17:13

我们还有许多使用 Delphi-7 运行 BDE 的应用程序,并且正在考虑跳转到 DelphiXE。跳转不太好...如果您希望程序在Windows7 64位中运行,您将需要转换BDE或下载BDE Express或其他工具。 BDE 存在内存泄漏问题,因此我们已经转换了这些组件,但旧产品仍保留在 Delphi-7 中,新项目则使用 Delphi XE。
祝你好运。

We also have many applications running BDE with Delphi-7 and are considering the jump to DelphiXE. The jump is not nice...if you want your program to run in Windows7 64 bit, you will need to convert the BDE or download BDE express or another tool. BDE has memory leak issues so we have converted those components, but will remain in Delphi-7 for older products and use Delphi XE for new projects.
Good Luck.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文