Unicode Strings

Just starting out? Need help? Post your questions and find answers here.
chris319
Enthusiast
Enthusiast
Posts: 782
Joined: Mon Oct 24, 2005 1:05 pm

Unicode Strings

Post by chris319 »

Version 5.72 x86
Windows 10

I am reviving an old program that works with PortAudio. The program worked perfectly to a point until I updated PB.

When I try to get device names from PortAudio, I'm getting Asian (unicode?) characters. I've tried using Ascii() but get numbers.

Code: Select all

device$(i) = DeviceString(*Devices(i))
Debug device$(i) ;gives "Asian" characters

device$(i) = DeviceString(*Devices(i))
Debug Ascii(device$(i)) ;gives numerals
How do I go about getting English ASCII strings and not numerals? I see nothing in Compiler Options that would help.

Thank you.
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4663
Joined: Sun Apr 12, 2009 6:27 am

Re: Unicode Strings

Post by RASHAD »

Maybe

Code: Select all

device$(i) = DeviceString(*Devices(i))
Debug device$(i) ;gives "Asian" characters

device$(i) = DeviceString(*Devices(i))
*Buff = Ascii(device$(i)) ;gives numerals
Debug PeekS(*Buff,-1,#PB_Ascii)
Egypt my love
wilbert
PureBasic Expert
PureBasic Expert
Posts: 3870
Joined: Sun Aug 08, 2004 5:21 am
Location: Netherlands

Re: Unicode Strings

Post by wilbert »

If you are using the procedures below (I found those on the forum), you probably need to change the PeekS to use #PB_Ascii.

Code: Select all

Procedure.s Pae_PaHostApiIndexToString(Ind)
  *info.PaHostApiInfo = Pa_GetHostApiInfo(Ind)
  ProcedureReturn PeekS(*info\name, -1, #PB_Ascii)
EndProcedure

Procedure.s DeviceString(*dev.PaDeviceInfo)
  ProcedureReturn PeekS(*dev\name, -1, #PB_Ascii) + " (" + Pae_PaHostApiIndexToString(*dev\hostApi) + ")"
EndProcedure
Windows (x64)
Raspberry Pi OS (Arm64)
chris319
Enthusiast
Enthusiast
Posts: 782
Joined: Mon Oct 24, 2005 1:05 pm

Re: Unicode Strings

Post by chris319 »

RASHAD wrote:Maybe

Code: Select all

device$(i) = DeviceString(*Devices(i))
Debug device$(i) ;gives "Asian" characters

device$(i) = DeviceString(*Devices(i))
*Buff = Ascii(device$(i)) ;gives numerals
Debug PeekS(*Buff,-1,#PB_Ascii)
Doesn't work. I get a bunch of question marks and a few ASCII characters.

This works:

Code: Select all

*Buff = @device$(i)
Debug PeekS(*Buff,-1,#PB_Ascii)
Thanks, Rashad.
Post Reply