How do I get string value?

Q: I am writing an application that iterates though Fields and Annots,
and sometimes it needs to go down to the dict entry level. The PDFNet
SDK provides very useful functions to retrieve variables of type
Boolean, Name and Number, but the support for String has been very
confusing, and the documentation in that area is deficient.

I could not find documentation for the UChar type. Some examples of
how to deal with them, in conjunction with UStrings would be welcome
by developers.

The documentation states that UStrings are not NULL terminated, but
some example of how to work around the obvious problem derived from
such that feature would be very helpful. Should I use GetBuffer() to
retrieve a dict string?

Additional question: what is the proper way to compare with a NULL?
See image.

Note: My current platform is Linux.
A: In PDF a string may represent an arbitrary chunk of memory (i.e. it
is not necessarily a null terminated string). In this case you can use
obj.GetBuffer() and obj.Size() to access data.

In case you know (e.g. via the spec) that you are dealing with text
strings you can use ebj.GetAsPDFText() which will return the Unicode
string. For example:

Obj t = dict.FindObj("T");
if (t != null) {
   string val = t.GetAsPDFText(); // We expect a string object

In C++:

Obj t = dict.FindObj("T");
if (t)
   UString n;
   cout << n;