title: Is there a way to see if a character is using 1 or 2 bytes in Delphi 2009?
body: <p>Delphi 2009 has changed its string type to use 2 bytes to represent a character, which allows support for unicode char sets.  Now when you get sizeof(string) you get length(String) * sizeof(char) .  Sizeof(char) currently being 2.  </p>
  
  <p>What I am interested in is whether anyone knows of a way which on a character by character basis it is possible to find out if it would fit in a single byte, eg find out if a char is ascii or Unicode.</p>
  
  <p>What I'm primarily interested in knowing, is before my string goes to a database (oracle, Documentum) how many bytes the string will use up.</p>
  
  <p>We need to be able to enforce limits before hand and ideally (as we have a large installed base) without having to change the database. If a string field allows 12 bytes, in delphi 2009 a string of length 7 would always show as using 14 bytes even though once it got to the db it would only use 7 if ascii or 14 if double byte, or somewhere in between if a mixture.</p>