static bool SizeConstByValTStr() { // always marshal managedArray.Length S_CHARArray_ByValTStr s = new S_CHARArray_ByValTStr(); s.arr = "有个可爱"; TakeByValTStr(s, s.arr.Length); // off by one byte since sizeconst == 4 and // number of bytes == 4 . We used to write // one past the buffer before but now we truncate at 3rd byte. // In order to test this the locale of the machine need to // a multibyte char set. s.arr = "个个"; TakeByValTStr(s, s.arr.Length); return true; }
static bool SizeConstByValTStr() { // always marshal managedArray.Length S_CHARArray_ByValTStr s = new S_CHARArray_ByValTStr(); s.arr = "abcd"; TakeByValTStr(s, s.arr.Length); // off by one byte since sizeconst == 4 and // number of bytes == 4 . We used to write // one past the buffer before but now we truncate at 3rd byte. // In order to test this the locale of the machine need to // a multibyte char set. s.arr = "个个"; TakeByValTStr(s, s.arr.Length); return(true); }
static extern bool TakeByValTStr(S_CHARArray_ByValTStr s, int size);