最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

delphi - Implicit string cast with potential data loss from 'string' to 'ShortString' - Stack Ov

programmeradmin1浏览0评论

I have several assignments like this (example):

string[50] := string + string

The length of string is mandatory (50...20...10...). This warning is generated:

W1058 Implicit string cast with potential data loss from 'string' to 'ShortString'

What cast can be done to eliminate this warning?

I have several assignments like this (example):

string[50] := string + string

The length of string is mandatory (50...20...10...). This warning is generated:

W1058 Implicit string cast with potential data loss from 'string' to 'ShortString'

What cast can be done to eliminate this warning?

Share Improve this question edited Jan 30 at 16:50 Remy Lebeau 598k36 gold badges503 silver badges848 bronze badges asked Jan 30 at 13:07 Robe79Robe79 575 bronze badges 2
  • Why did you remove "1" (and renumbered "2" to "1")? – HeartWare Commented Jan 30 at 13:41
  • @HeartWare Because unrelated questions should be asked separately. The first question warrants its own post. – Remy Lebeau Commented Jan 30 at 16:55
Add a comment  | 

1 Answer 1

Reset to default 1

To eliminate (suppress - ie. not a fix) the warning, do an explicit type cast to ShortString:

string[50] := ShortString(string + string)

But, you are only suppressing the warning. If string (or string) contain characters that can't be represented in 8-bit in your current locale, you'll get '?' characters instead.

As you can see, it's an uphill battle to try to force the UNICODE compiler to work in ANSI mode. You would be much better off to simply convert your code to full UNICODE from the bottom up.

发布评论

评论列表(0)

  1. 暂无评论