[Mono-dev] Strings and Unicode in Mono/.NET

Rafael Teixeira monoman at gmail.com
Sun Sep 30 19:13:02 EDT 2007


On 9/30/07, Cetin Sert <cetin.sert at gmail.com> wrote:
> 1.       a) What is the maximum string length? Is it Int32.Max / 2?

No it is Int32.Max (which is near UInt32.Max)

		[NonSerialized] private int length;

But yes it is limited to some 2GB per string.

>  b) (If it is indeed Int32.Max / 2,) why is that so? What about newer
> computers with 64-bit CPUs and very large memories?

As always it was a decision about the costs/benefits, of implementing
it in other ways, at the moment MS was creating it some decade ago and
considering the evolution in the foreseeable future, at that time. I
think their decision is still valid for the majority of uses.

Those that really need to have bigger strings (it seems like some real
bad design not to break any such big amount of text into smaller
pieces, like per-paragraph, or blocks), can implement an String64 type
with conversions to the base string type where appropriate and

Some specialized IO classes would also need to be done, if someone
would really need to read a 16GB text file, for instance, at once into
an String64 variable, but even with huge amounts of memory and
blindingly fast CPUs  that would be slow as persistent storage is
still order-of-magnitude slower than memory/CPU, but alas...

I don't think, MS and ECMA will address that issue anytime soon,
providing an standard way to deal with it, so custom (hopefully open)
implementations of this String64 concept, for the few that really will
need it, will surely be the first to appear.

>  c) What about the many APIs in core libraries that use Int32 as index
> parameter?

The ones in the String class would be duplicated/extended in the
String64 class, anyway. The others would need to again have evaluated
their costs/benefits between at least two paths: 1) to write and
maintain duplicated versions for String64 parameters, or simply to 2)
to split/join in the application the instances of String64 into/from
arrays of strings to use the older APIs.

> 2.       What is the Unicode version .NET 2.0 and 3.5 support and what
> version does Mono support?

Not sure, but I guess it is 3.x for .NET 2.0. No idea for .NET 3.5,
Mono matches .NET 2.0 in that regard, AFAIK.

> Best Regards,
> Cetin Sert

Hope it helps,

Rafael "Monoman" Teixeira
"I myself am made entirely of flaws, stitched together with good intentions."
Augusten Burroughs

More information about the Mono-devel-list mailing list