Just 3 days after we released the new Delphi Certification Program, many Delphi developers around the world already became Certified Delphi Developer.
In order to encourage others, I decided to start writing tips for the Delphi Certification Program, which will help you during your preparation for the exam. The Delphi Developer Certification Study Guide is the official guide and provide all of the information you need to be ready for the exam. My tips are a complementary material and doesn’t replace the Study Guides.
I won’t be posting questions and/or answers related with the exam. My goal here is to help you to be ready for the exam, learn more about Delphi, be a better developer, improve your skills and chances to become Delphi Developer Certified.
To start, let’s learn about System.RawByteString type and improve our knowledge on Unicode support, the exam may ask you directly or indirectly about this matter.
RawByteString is one of the new String types introduced in Delphi 2009 because of the Unicode support. RawByteString is an AnsiString with no code page set by default. Each string in Delphi is associated with a code page. The runtime library uses this information to safely convert and manipulate international character sets. RawByteString can be used as a variable type to store some BLOB data and should be use as a code page agnostic parameter to a method or function.
The RAD Studio documentation describes RawByteString as:
Enables the passing of string data of any code page without doing any codepage conversions.
RawByteString enables the passing of string data of any code page without doing any codepage conversions. The purpose of RawByteString is to reduce the need for multiple overloads of procedures that read string data. This means that parameters of routines that process strings without regard for the string’s code page should typically be of type RawByteString.
RawByteString should only be used as a parameter type, and only in routines which otherwise would need multiple overloads for AnsiStrings with different codepages. Such routines need to be written with care for the actual codepage of the string at run time.
In general, it is recommended that string processing routines should simply use “string” as the string type. Declaring variables or fields of type RawByteString should rarely, if ever, be done, because this practice can lead to undefined behavior and potential data loss.
Below three links I recommend you read:
- Delphi Unicode Migration for Mere Mortals: Stories and Advice from the Front Lines
- Using RawByteString Effectively
- RAD Studio Documentation – String Types (Delphi) – already mentioned on the Study Guide
Reading this information you will be able to answer questions related with RawByteString and Unicode, and the most important learn more about Delphi.