New topic: 

Default character encoding is not always UTF-8?

<http://forums.realsoftware.com/viewtopic.php?t=38414>

         Page 1 of 1
   [ 3 posts ]                 Previous topic | Next topic          Author  
Message        basil.bourque          Post subject: Default character encoding 
is not always UTF-8?Posted: Wed Mar 30, 2011 6:24 pm                         
Joined: Thu Apr 15, 2010 10:41 pm
Posts: 209
Location: Seattle                I have found a case where REALbasic is 
generating a string in US-ASCII encoding rather than UTF-8. 

Is this a bug?

Yes, I know UTF-8 is a superset of US-ASCII. But my understanding is that, by 
default, REALbasic strings are UTF-8.

Code:  // x
  dim now as new Date
  dim x as String = str( now.GMTOffset ) 
  dim x_enc as TextEncoding = x.Encoding  // Reports US-ASCII
  
  // y
  dim y as String = "whatever"
  dim y_enc as TextEncoding = y.Encoding  // Reports UTF-8
  
  MsgBox "Encoding of x is " + x_enc.internetName
  MsgBox "Encoding of y is " + y_enc.internetName
      
_________________
--Basil Bourque

Using REAL Studio 2010 r5.1 with Postgres 9.0.3 on Mac OS X 10.6.5
http://crafted-software.blogspot.com/  
                             Top                 basil.bourque          Post 
subject: Re: Default character encoding is not always UTF-8?Posted: Wed Mar 30, 
2011 6:48 pm                         
Joined: Thu Apr 15, 2010 10:41 pm
Posts: 209
Location: Seattle                I determined the problem is in calling "str" 
on an integer.

Simpler code:
Code:  dim x_enc as string = str( 7 ).Encoding.internetName // Reports 
"US-ASCII".
  dim y_enc as string = str( "7" ).Encoding.internetName  // Reports "UTF-8".

Not the end of the world, but this did trip up some paranoid error-checking 
where I was verifying that strings are in UTF-8 before shipping them off to the 
database.

Reported this as a bug.      
_________________
--Basil Bourque

Using REAL Studio 2010 r5.1 with Postgres 9.0.3 on Mac OS X 10.6.5
http://crafted-software.blogspot.com/  
                             Top                 mjh          Post subject: Re: 
Default character encoding is not always UTF-8?Posted: Wed Mar 30, 2011 7:29 pm 
                                
Joined: Sun Feb 19, 2006 3:10 pm
Posts: 1175
Location: Hamburg, Germany                basil.bourque wrote:But my 
understanding is that, by default, REALbasic strings are UTF-8.
An ASCII string is an UTF-8 string … Anyway, while string literals are 
documented to be UTF-8, I’m not sure that is necessarily true for strings 
returned by the built-in functions. Since the result of Str is guaranteed to be 
comprised of ASCII characters only, using ASCII as the encoding should be fine. 
The encoding of the empty string is also reported as being ASCII, by the way.   
   
_________________
Michael J. Hußmann 
http://digicam-experts.de  
                             Top             Display posts from previous: All 
posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost 
timeSubject AscendingDescending          Page 1 of 1
   [ 3 posts ]      
-- 
Over 1500 classes with 29000 functions in one REALbasic plug-in collection. 
The Monkeybread Software Realbasic Plugin v9.3. 
http://www.monkeybreadsoftware.de/realbasic/plugins.shtml

[email protected]

Reply via email to