peek_string
| Definition: |
string s = peek_string(atom addr)
-- or -- sequence s = peek_wstring(atom addr) |
| Description: | Retrieve a string or widestring that starts at the supplied memory address. |
| pwa/p2js: | Not supported. |
| Comments: |
Reads characters until a terminating null is found.
In some cases a fixed size is used to hold a string, for example the Names in the Section Table of a PE format file (such as .text, .data) are x8 and may not always have a terminating zero. Either use peek({addr,8}) and trim the result if it contains any null characters, or, slightly less safe, use peek_string but crop the result if it is more than 8 characters. If the supplied address is NULL, peek_string() yields "" and peek_wstring yields {}. It may be useful to pass the result of peek_wstring() through utf16_to_utf8(). |
| Example: |
atom title
title = allocate_string("The Wizard of Oz")
?peek_string(title)
...
free(title)
For a complete runnable program, see rosetta\7guis\Cells.exw |
| Implementation: | See builtins\peekstr.e (an autoinclude) for details of the actual implementation. |
| See Also: | allocate_string, allocate, free, utf16_to_utf8 |