Jump to content

Null character & String* Function


DXRW4E
 Share

Recommended Posts

Seems that once find the Null character String(StripAdd)CR ignore the rest of the StringTexData, is this normal ?, because for example i am forced to use the StringRegExpReplace($sData, "r", "") and not StringStripCR($sData) ect ect, to be sure to always have all the StringTexData

Ciao.

Edited by DXRW4E

apps-odrive.pngdrive_app_badge.png box-logo.png new_logo.png MEGA_Logo.png

Link to comment
Share on other sites

In Windows, a string is terminated by the NUL character. If it's not text, it's not really a string, it's binary. String functions don't work well with binary data.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

In Windows, a string is terminated by the NUL character.

Yes, I know that, in fact I asked to know if is possible do something to improve them in this case (because it looks like a problem of String(StripAdd)CR ect ect, because the StringTrim* & StringLen ect ect working OK, because I think the same thing for the StringLen normally had to have the same problem, instead StringLen is Ok), or need to always use the StringRegExp*, because in this case remains to ignore String* Function, and use only the StringRegExp* to be 100% safe ect ect

Ciao.

Edited by DXRW4E

apps-odrive.pngdrive_app_badge.png box-logo.png new_logo.png MEGA_Logo.png

Link to comment
Share on other sites

I don't think that StringStrip* is a problem, it appears to be working ok to me. The example in the help file for StringStripWS works, except that the message box doesn't display the string correctly if I insert a chr(0) in it.

#include <MsgBoxConstants.au3>
#include <StringConstants.au3>
; Strip leading and trailing whitespace as well as the double spaces (or more) in between the words.
Local $sString = StringStripWS("   This   is   a   sentence   with" & chr(0) & "   whitespace.    ",  $STR_STRIPALL  )
MsgBox($MB_SYSTEMMODAL, "", StringLen($sString))
MsgBox($MB_SYSTEMMODAL, "", $sString)

The length displays correclty, the string in the msgbox doesn't.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

(because it looks like a problem of String(StripAdd)CR ect ect, because the StringTrim* & StringLen ect ect working OK, because I think the same thing for the StringLen normally had to have the same problem, instead StringLen is Ok)

I am referring to StringStripCR, seem only the String(StripAdd)CR have a problem, all others seem okkk, or asked for this reason, because I think maybe can do something there, as not all String Functions have this problem, when normally they had to have all the same problem
 
Ciao.
Edited by DXRW4E

apps-odrive.pngdrive_app_badge.png box-logo.png new_logo.png MEGA_Logo.png

Link to comment
Share on other sites

Sorry, I thought you were referring to the StringStrip* functions in general.

I tested this, and it appears to be a bug with those functions because the other String functions appear to be working ok. I'd report it as a bug rather than as a feature request.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

  • Administrators

Over time most of the AutoIt string functions have migrated to an internal string object that stores the length so that you can work with strings with nulls in them without too much trouble. Some APIs - like MsgBox - might not show the text correctly but as you've seen in this thread the nulls are usually preserved.  StringStripCR/AddCR look to be leftover functions that are only processing null terminated strings.  I'll update them.

Link to comment
Share on other sites

Hi Jon, now I've noticed that even the StringRegExp (StringRegExpReplace is Ok, even StringSplit is Ok that return array) that does not seem OK

local $b, $a = StringRegExp("aaa" & chr(0) & "bbbccc", 'aaa\x00bbb', 1)
$b = @extended
ConsoleWrite("@extended - " & $b & @LF)
ConsoleWrite("StringLen - " & StringLen($a[0]) & @LF)
exit

;~ >Running:(3.3.9.23):C:\Program Files (x86)\AutoIt3\Beta\autoit3.exe "C:\Users\DXRW4E\Desktop\New AutoIt v3 Script.au3"    
;~ --> Press Ctrl+Alt+F5 to Restart or Ctrl+Break to Stop
;~ @extended - 8
;~ StringLen - 3
;~ +>08:31:35 AutoIt3.exe ended.rc:0
;~ >Exit code: 0    Time: 0.423

the return array is not OK, because the extended looks OK

Ciao.

Edited by DXRW4E

apps-odrive.pngdrive_app_badge.png box-logo.png new_logo.png MEGA_Logo.png

Link to comment
Share on other sites

  • 1 month later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...