[Solved] Non-Unicode data type for Basic

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
brainwav
Posts: 7
Joined: Fri Feb 01, 2008 4:35 pm

[Solved] Non-Unicode data type for Basic

Post by brainwav »

Hi, are there any non-unicode text/string data types for Basic? I think I have a problem with sending a string over DDE. The receiving app does not support unicode and cuts off the string at one character. I was told this is because the app doesnt support unicode characters. How do I define that I don't want to use the unicode data types?

Is there a way to create new data types like in C++?

Thanks,
Brainwav
Last edited by brainwav on Wed Feb 13, 2008 4:17 pm, edited 1 time in total.
brainwav
Posts: 7
Joined: Fri Feb 01, 2008 4:35 pm

Re: non-Unicode data type for Basic

Post by brainwav »

Ok, I figured things out. I wrote a function that converts a unicode string to a non-unicode format using unnicode strings. It worked for what I was doing. Basically unicode strings have 2 bytes per character, so I skwiched the the bytes together. Heres the code:

Code: Select all

Function ConvertUnicode( start as String ) as String
	Dim finish as String
	length = len( start )
'	print "Unicode Length = " & length
	finish = ""

	for i = 1 to length step 2
		a = asc( mid$( start, i, 1 ) )
		
		if ( ( i+1 ) <= length ) then
			b = asc( mid$( start, i+1, 1 ) )
			c = a + ( b * 256 )
			finish = finish & chr( c )
		else
			finish = finish & chr( a )
		end if
	next i
	
	ConvertUnicode = finish
end Function
Brainwav.
Post Reply