Actually you're right, as the bare minimum for PB is OS X 10.5, and this one already supports 64-bitwilbert wrote:@Marroh,
Mac is so modern that one single 64 bit unicode version would probably be good enough for most Mac users

Actually you're right, as the bare minimum for PB is OS X 10.5, and this one already supports 64-bitwilbert wrote:@Marroh,
Mac is so modern that one single 64 bit unicode version would probably be good enough for most Mac users
As I said, I use ascii almost exclusively. Removing ascii will create much work for me. However, I do see the merits of it.Fred wrote:It's not decided for now
True, and that's a valid point for the average program with a GUI, user input, a lot of idle time and doing a normal use of strings.freak wrote: The reason is that the entire OS layer is Unicode (at least on Windows), so in an ascii program, every call to an API function must be converted from ascii->unicode and back for the result.
Definitely not true if you use the string library on substantial strings.freak wrote: A unicode program is definitely not slower than an ascii one.
Code: Select all
ntimes = 100000
time1 = ElapsedMilliseconds()
For k = 1 To ntimes
a$ = a$ + "*"
b$ = Mid(a$, Len(a$) / 2, 1)
Next
time2 = ElapsedMilliseconds() - time1
MessageRequester("Run 1", "Time = " + Str(time2))
Unicode strings in PB, much slower than the ASCII. And this problem is not solved! http://www.purebasic.fr/english/viewtop ... =3&t=58892freak wrote:About the speed:
Code: Select all
DisableDebugger
Str.s
#Text = "1234567890"
Time = ElapsedMilliseconds()
For i=1 To 10000
Str + #Text
Next i
MessageRequester("", StrF((ElapsedMilliseconds()-Time)/1000, 3))
Here on Mac:User_Russian wrote:Unicode strings in PB, much slower than the ASCII.freak wrote:About the speed:
Fred simply can't add OOP support to PB because it adds overhead and may be slower in some circumstances, and User_Russian would only complain.PureBasic V4.00 (May 2006)
- Added: Native unicode support
The point is there is a great speed difference compiling the same code in the two different modes, so telling "A unicode program is definitely not slower than an ascii one" is false. I'm interested only in that statement.Shiled wrote: It's a terrible example because any sane person would use a string builder or other mechanisms for this.
Code: Select all
Function() (Ascii)
Function_THREAD() (Ascii + Threaded)
Function_UNICODE (Unicode)
Function_UNICODE_THREAD (Unicode + Threaded)
Function_Debug() (Runtime Debug)
Code: Select all
- Ascii
- Ascii MMX
- Ascii SSE
- Ascii SSE2
- Ascii SSE3
- Ascii SSE4
- Threaded Ascii
- Threaded Ascii MMX
- Threaded Ascii SSE
- Threaded Ascii SSE2
- Threaded Ascii SSE3
- Threaded Ascii SSE4
- Unicode
- Unicode MMX
- Unicode SSE
- Unicode SSE2
- Unicode SSE3
- Unicode SSE4
- Threaded Unicode
- Threaded Unicode MMX
- Threaded Unicode SSE
- Threaded Unicode SSE2
- Threaded Unicode SSE3
- Threaded Unicode SSE4
- Debug
Code: Select all
/* === Copyright Notice ===
*
*
* PureBasic source code file
*
*
* This file is part of the PureBasic Software package. It may not
* be distributed or published in source code or binary form without
* the expressed permission by Fantaisie Software.
*
* By contributing modifications or additions to this file, you grant
* Fantaisie Software the rights to use, modify and distribute your
* work in the PureBasic package.
*
*
* Copyright (C) 2000-2010 Fantaisie Software - all rights reserved
*
*/
#include "String.h"
#ifdef WINDOWS
// see http://blogs.msdn.com/oldnewthing/archive/2010/03/05/9973225.aspx
#define INFINITY ((float)(1e308 * 10))
#define NAN ((float)((1e308 * 10)*0.))
#include <locale.h>
#else
#include <math.h>
#endif
M_PBFUNCTION(double) PB_ValD(const TCHAR *String)
{
if (String == NULL)
return 0;
if (stricmp(String, TEXT("+Infinity")) == 0)
{
return (double)INFINITY;
}
else if (stricmp(String, TEXT("-Infinity")) == 0)
{
return -(double)(INFINITY);
}
else if (stricmp(String, TEXT("NaN")) == 0)
{
return (double)NAN;
}
#ifdef WINDOWS
setlocale(LC_NUMERIC, "English"); // on Windows, the local can be changed, so update it (3x slower now) ! http://www.purebasic.fr/english/viewtopic.php?f=4&t=47944&start=30
#endif
#ifdef UNICODE
#ifdef WINDOWS
{
double Result = 0;
sscanf(String, TEXT("%lf"), &Result);
return Result;
}
#else
char Buffer[1024];
int Length;
Length = SYS_WideCharToMultiByte(CP_ACP, 0, String, -1, Buffer, 1023, 0, 0);
Buffer[Length] = 0;
#if defined(LINUX) && !defined(PB_MACOS)
PB_String_ReplaceDecimalCharacter(Buffer);
#endif
return atof(Buffer); // returns a double on linux
#endif
#else
#if defined(LINUX) && !defined(PB_MACOS)
double Result = 0;
char *ConvertedString;
if (ConvertedString = strdup(String))
{
PB_String_ReplaceDecimalCharacter(ConvertedString);
Result = atof(ConvertedString);
free(ConvertedString);
}
return Result;
#else
return atof(String);
#endif
#endif
}