Re: stringtochar function

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Mon Jul 09 2012 - 09:45:06 MDT

The character you're seeing is a NULL character. This will always be appended when you call stringtochar.

I believe the reason for this NULL character is for the case where you give it an array of strings. Since each string may be a different length, it becomes
necessary to have something that denotes the actual end of each string

To correctly get the string length, you need to subtract 1:

  s = "123456789"
  c = stringtochar(s)
  clen = dimsizes(c) -1
  print("length of c = " + clen)

(0) length of c = 9

--Mary

On Jul 8, 2012, at 11:27 PM, Xin Xi wrote:

> Hi there,
> when I use the stringtochar function, the resulting char array has an ending element of "0x00". This cause the unmatched dimension size error while I tried to assign the char array to a variable (with a dimension of the string length). I donot understand how the "0x00" relates to the missing value of original string (as detailed on the ncl webpage of the stringtochar function). And how can I avoid it? Can someone clarify for me. Thanks!
> Xin
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Mon Jul 9 09:45:16 2012

This archive was generated by hypermail 2.1.8 : Mon Jul 09 2012 - 10:45:32 MDT