forum.vdsworld.com Forum Index forum.vdsworld.com
Visit VDSWORLD.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


How to read a Unicode file
Goto page 1, 2  Next
 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help
View previous topic :: View next topic  
Author Message
bbelcher
Contributor
Contributor


Joined: 30 Jul 2002
Posts: 172

PostPosted: Fri Apr 16, 2004 2:38 pm    Post subject: How to read a Unicode file Reply with quote

Hello I'm trying to load a file into a list but it's encoded in unicode format. How do I read it?


Code:

Title test
  DIALOG CREATE,New Dialog,-1,0,240,310
  DIALOG ADD,BUTTON,BUTTON1,14,10,64,24,BUTTON1
  DIALOG ADD,LIST,LIST1,53,7,224,245
  DIALOG SHOW

:Evloop
  wait event
  goto @event()
:BUTTON1BUTTON
list create,1
run cmd.exe /c C:\winnt\servicepackfiles\i386\msinfo32 /categories +SystemSummary /report c:\test.txt,wait
list loadfile,list1,c:\test.txt
if @match(list1,~1992)
info yes
else
info no
end
list close,1
  goto evloop
:Close
  exit
[/code]
Back to top
View user's profile Send private message
bbelcher
Contributor
Contributor


Joined: 30 Jul 2002
Posts: 172

PostPosted: Fri Apr 16, 2004 3:07 pm    Post subject: Reply with quote

I fiqured it out kind of but I would still like to know how to view Unicode files in VDS.

Code:

Title test
  DIALOG CREATE,New Dialog,-1,0,119,102
  DIALOG ADD,BUTTON,BUTTON1,23,26,64,24,BUTTON1
  DIALOG SHOW

:Evloop
  wait event
  goto @event()
:BUTTON1BUTTON
list create,1
runh cmd.exe /c c:\winnt\servicepackfiles\i386\msinfo32 /categories +SystemSummary /report c:\test.txt &&type c:\test.txt,pipe,wait
%%pipe = @pipe()
list add,1,%%pipe
rem ~1992 is cpu speed
if @match(1,~1992)
info yes
else
info no
end
list close,1
  goto evloop
:Close
  exit
Back to top
View user's profile Send private message
Skit3000
Admin Team


Joined: 11 May 2002
Posts: 2166
Location: The Netherlands

PostPosted: Fri Apr 16, 2004 3:09 pm    Post subject: Reply with quote

Maybe you can post the contents of the file you get with your script? To do this, just insert this line before the if line:

Code:
clipboard set,@text(1)

_________________
[ Add autocomplete functionality to your VDS IDE windows! ]
Voor Nederlandse beginners met VDS: bekijk ook eens deze tutorial!
Back to top
View user's profile Send private message
bbelcher
Contributor
Contributor


Joined: 30 Jul 2002
Posts: 172

PostPosted: Fri Apr 16, 2004 3:24 pm    Post subject: Reply with quote

I not sure if that will work because the Unicode test.txt file when read by vds returns &!^ or something similar. But if opened by notepad or using the type command in a command window it returns all the appropriate information.
Back to top
View user's profile Send private message
FreezingFire
Admin Team


Joined: 23 Jun 2002
Posts: 3508

PostPosted: Fri Apr 16, 2004 5:27 pm    Post subject: Reply with quote

You could try using BINFILE. Smile
_________________
FreezingFire
VDSWORLD.com
Site Admin Team
Back to top
View user's profile Send private message Visit poster's website
Mac
Professional Member
Professional Member


Joined: 08 Jul 2000
Posts: 1585
Location: Oklahoma USA

PostPosted: Fri Apr 16, 2004 8:46 pm    Post subject: Reply with quote

Or VDSug.dll - it allows you to load raw file data by choosing
a replacement char for "null" chars, which normally signify the
end of a string to VDS. Wink

Cheers, Mac Smile

_________________
VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361
Back to top
View user's profile Send private message Send e-mail
vtol
Valued Contributor
Valued Contributor


Joined: 05 Feb 2004
Posts: 656
Location: Eastern Indiana

PostPosted: Fri Apr 16, 2004 11:38 pm    Post subject: Reply with quote

I'm having simular problems right now related to RUN cmd.exe DIR getting files in list.

I've seen that '&amp' before, and am curiuos what that means and what its used for ?

Goodluck.. Smile
Back to top
View user's profile Send private message Visit poster's website
vtol
Valued Contributor
Valued Contributor


Joined: 05 Feb 2004
Posts: 656
Location: Eastern Indiana

PostPosted: Fri Apr 16, 2004 11:48 pm    Post subject: Reply with quote

I found this random unicode link on GOOGLE and downoaded the 1st unicode file on this page:

http://crl.nmsu.edu/~mleisher/download.html

Now I'm gonna try to get it to read in VDS5... (I know hardly nothing about unicode files)
Back to top
View user's profile Send private message Visit poster's website
Garrett
Moderator Team


Joined: 04 Oct 2001
Posts: 2149
Location: A House

PostPosted: Sat Apr 17, 2004 12:03 am    Post subject: Reply with quote

Do a search of the forum here. I helped someone before with the unicode
stuff and it doesn't require any external dll. But I can't remember if the
code for it was posted on the forum or not.

If you can't find the code around the forum, I'll have to search my own
archives to see if I still have the code here locally.

_________________
'What you do not want done to yourself, do not do to others.' - Confucius (550 b.c. to 479 b.c.)
Back to top
View user's profile Send private message
vtol
Valued Contributor
Valued Contributor


Joined: 05 Feb 2004
Posts: 656
Location: Eastern Indiana

PostPosted: Sat Apr 17, 2004 12:20 am    Post subject: Reply with quote

I did this:

Code:
DIALOG ADD,BUTTON,testing,134,20,40,17,Testing
DIALOG SHOW

LIST CREATE,1

:EVLOOP 
 WAIT EVENT 
 GOTO @EVENT() 

:TestingBUTTON
LIST clear,1
DIALOG clear,listbox
LIST loadfile, 1,c:\vds5\zzz\cu-alt12.bdf
LIST append,listbox, 1
goto evloop

:close
LIST close,1
exit


and saw some dollar signs '$' (is that the problem?)
ListBox window wrote:
STARTFONT 2.1
$Id: cu-alt12.bdf,v 1.12 2002/11/22 22:46:24 mleisher Exp $
Back to top
View user's profile Send private message Visit poster's website
vtol
Valued Contributor
Valued Contributor


Joined: 05 Feb 2004
Posts: 656
Location: Eastern Indiana

PostPosted: Sat Apr 17, 2004 12:22 am    Post subject: Reply with quote

Will this help?

Code:
DIALOG CREATE,testing,-1,0,589,155
DIALOG ADD,BITLIST,listbox,15,6,578,115
DIALOG ADD,BUTTON,testing,134,20,40,17,Testing
DIALOG ADD,BUTTON,convert,134,120,110,17,Convert to Text
DIALOG SHOW

LIST CREATE,1

:EVLOOP 
 WAIT EVENT 
 GOTO @EVENT() 

:TestingBUTTON
LIST clear,1
DIALOG clear,listbox
LIST loadfile, 1,c:\vds5\zzz\cu-alt12.bdf
LIST append,listbox, 1
goto evloop

:convertBUTTON
LIST clear,1
DIALOG clear,listbox
LIST loadfile, 1,c:\vds5\zzz\cu-alt12.bdf
LIST append,listbox, 1
LIST savefile,listbox,c:\vds5\zzz\unicode-test.txt
goto evloop

:close
LIST close,1
exit


It converts a unicode file to a text file.. What else is needed?
I tryed adding SORTED to list 1, but it never removed the COMMENT words Confused
Back to top
View user's profile Send private message Visit poster's website
bbelcher
Contributor
Contributor


Joined: 30 Jul 2002
Posts: 172

PostPosted: Sat Apr 17, 2004 12:28 am    Post subject: Reply with quote

I'll Give it a try and see what happends..

Thanks..
Back to top
View user's profile Send private message
FreezingFire
Admin Team


Joined: 23 Jun 2002
Posts: 3508

PostPosted: Sat Apr 17, 2004 12:30 am    Post subject: Reply with quote

Vtol, what you downloaded doesn't appear to be a unicode file. You can
make a unicode formatted file by opening notepad, typing a little text,
then go to File > Save As, and where the combo box says "ANSI" change
it to "Unicode". Then save the file under the name of your choice, and
finally load that file in VDS. Smile

When read by VDS, the result of reading the unicode file is:
Code:
˙ūT


This text remains constant no matter what content is in the file.

For more information on unicode text, visit:
http://www.unicode.org/standard/WhatIsUnicode.html

_________________
FreezingFire
VDSWORLD.com
Site Admin Team
Back to top
View user's profile Send private message Visit poster's website
vtol
Valued Contributor
Valued Contributor


Joined: 05 Feb 2004
Posts: 656
Location: Eastern Indiana

PostPosted: Sat Apr 17, 2004 12:39 am    Post subject: Reply with quote

I did what FreezingFire said to create a unicode file and got a ˙ūV...

yuk.... Embarassed I see what you mean

Thats a lot worse string problem than I have, I'm just stumped in my POST.

You gotta find that pre-written code Garrett mentioned, sorry to waste your time buddy Cool (if I think of something I can test it now - GL)
Back to top
View user's profile Send private message Visit poster's website
Garrett
Moderator Team


Joined: 04 Oct 2001
Posts: 2149
Location: A House

PostPosted: Sat Apr 17, 2004 6:29 am    Post subject: Reply with quote

Ok, here's all I could find in my archives, and I can't remember who I was
helping on this. Who ever it was has a complete program working now
that converts the unicode to a format that VDS can use. The following
example only shows how to read in the unicode file in hex format, and then
to convert the hex code to ascii codes. This then gives you the chance to
seek out the ascii values which do not show up in VDS and replace them
with appropriate values that do. I wish I had the rest of the code for this,
but this is all I've got Sad

Code:
  DIALOG CREATE,New Dialog,0,0,400,600,DRAGDROP
  DIALOG ADD,STYLE,STYLE1,Courier New,8,,,
  DIALOG ADD,LIST,List1,0,0,400,300,,STYLE1
  DIALOG ADD,LIST,LIST3,300,0,400,300,,STYLE1
  DIALOG SHOW

:EventLoop
  Wait Event
  %E = @event()
  If %E
    Goto %E
  End

:CLOSE
  Exit

:DRAGDROP
  List Create,1
  List Dropfiles,1
  List Create,2
  List Create,3
REM --- Drop file on dialog.  Use binfile to open.  I'm not very
REM --- familiar with this binfile stuff, so I can't offer too
REM --- much help with that part.
  BINFILE OPEN,1,@item(1,0),READ
  %A = @BINFILE(SIZE,1)
  %S = 0
     binfile seek,1,%S
     while @not(@binfile(EOF,1))
        REM --- Read it in as HEX format
       %D = @binfile(read,1,HEX,16)
         binfile seek,1,%S
      %T = @binfile(read,1,TEXT,16)
      If @greater(48,@len(%D))
        Repeat
          %D = %D" "
        until @equal(@len(%D),4Cool
      End
      List add,List1,%D
      %S = @sum(%S,16)
     wend
  BINFILE CLOSE,1
  %A = @path(@item(1,0))@name(@item(1,0))2.@ext(@item(1,0))
  list Close,1
  list close,2
  List Append,3,List1
  List Seek,3,0
  REM --- Copy list1 to 3
  Repeat
    REM --- there's a space between each hex value, so we
    REM --- need to skip the spaces while we convert.  We
    REM --- set two variables "%1 and %2" for our
    REM --- @substr() routine
    %1 = 1
    %2 = 2
    %%Converted =
    Repeat
      %%Cur =
      %%Cur = @substr(@item(3),%1,%2)
      REM --- Grab the hex value in %%Cur
      If %%Cur
        REM --- Convert the hex code in %%Cur to ascii value, not
        REM --- character, just ascii value.  I'm adding a space
        REM --- between each value so that each value can eventually
        REM --- be converted to some sort of character.  @sum($<hexvalue>,0)
        REM --- is what converts the hex value to an ascii value.
        %%Cur = @sum($%%Cur,0)" "
        REM --- Add the %%Cur to our current row of converted values.
        %%Converted = %%Converted%%Cur
      End
      REM --- increase the @substr() values by 3 to get the next hex value.
      %1 = @sum(%1,3)
      %2 = @sum(%2,3)
    Until @null(%%Cur)
    LIst Add,List3,%%Converted
    %%Null = @next(3)
  Until @null(@item(3))
  REM --- list2 now has hex values and list3 has the ascii values.
  REM --- From here, you'd want to loop through list3 and convert ascii values
  REM --- to characters, but! You'll want to seek out the ones that will not
  REM --- display in VDS and convert them to something that will.
  REM ---
  REM --- Once you've edited, then you'll want to reverse this process and
  REM --- convert the text all back to ascii values using @asc(), replace the
  REM --- ascii values that you changed above to their original ascii values.
  REM --- And finally, convert the ascii values to hex using
  REM --- @hex(<asciivaluehere>,2), and save it back out using BINFILE.
  Goto EventLoop

_________________
'What you do not want done to yourself, do not do to others.' - Confucius (550 b.c. to 479 b.c.)
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum

Twitter@vdsworld       RSS

Powered by phpBB © 2001, 2005 phpBB Group