get string from cursor safely