Bytes vs Text
Your extension exchanges files with a Nordic logistics partner: you hand their portal a blob, they hand one back. Their spec is blunt — "UTF-8 or UTF-16, tell us which, and don't choke on a byte order mark". Half the encoding bugs in real Business Central projects trace back to a stream that was opened without saying which encoding it speaks, and the corrupted æøå is found in production weeks later. You are writing the one codec both directions go through, and it is graded on the exact bytes.
Requirements
Create a codeunit named "Text Blob Codec" with two public procedures:
procedure ExportText(Content: Text; Encoding: TextEncoding; var TempBlob: Codeunit "Temp Blob")
procedure ImportText(TempBlob: Codeunit "Temp Blob"; Encoding: TextEncoding): TextRules — this is the whole contract, and every rule is graded:
ExportTextreplaces the blob's content entirely: afterwards the blob holds exactly the bytes ofContentencoded withEncoding— no byte order mark of your own, no terminator, and no stale bytes left over from whatever the blob held before. Callers reuse one blob across exports.- Exporting empty text produces a zero-length blob.
Solve it with Pro
You’re reading the opening of the statement. Pro unlocks the whole problem:
- The full statement
- Starter code in the browser editor
- 14 grading tests, run on Business Central 28.5
- 3 hints
- The reference solution
Pro also opens all 92 Pro problems and lifts the daily limits on compile checks and submissions.
Already on Pro? Sign in