Hi I have the following code
delete: = 'testing # {}' testing ';
the problem is that when I use 'fails because it does not know how to avoid this error in other languages such as perl is solved by using \' delphi but does not work.
someone could help form the variable without errors?
Assuming that your problem is trying to put a quote character inside a string literal, then try this:
delete := 'testing # {}'' testing ';
Related
I'm using the following code to show description in template:
json.description resource.description if resource.description.present?
It gives me invalid byte sequence in UTF-8 error. I dig this a little bit, and find out the issue is my description has single quote as ’ instead of '. Wondering what's the best way to fix this encoding issue? Description is input by user and I have no control over it. Another weird issue is, I have multiple test environments, they all have the same Ruby and Rails version and they are running the same code, but only one of the environment has this error.
def to_utf8(str)
str = str.force_encoding("UTF-8")
return str if str.valid_encoding?
str = str.force_encoding("BINARY")
str.encode("UTF-8", invalid: :replace, undef: :replace)
end
ref: https://stackoverflow.com/a/17028706/455770
I want to get onclick="alert('myvar')" in the browser.
I tried
th:onclick="'alert(\'' + ${myVar} + '\');'"
and I got
onclick="alert('null');"
I tried
th:onclick="|alert('${myVar}');|"
and I still got
onclick="alert('null');"
How can I let the single quote not be escaped?
The following snipped worked for me:
th:onclick="|alert('${myVar}');|"
That looks like your second attemp but I'm getting:
onclick="alert('null');"
That makes me thinking and I tested your first attemp:
th:onclick="'alert(\'' + ${myVar} + '\');'"
and again I'm getting:
onclick="alert('null');"
Spooky! I searched for similar questions in the thymleaf-forum afterwards and that's the way how to to this.
Hello I am writing a scipt on ROBLOX and I have encountered a problem.
function showVictoryMessage(playerName)
local message = Instance.new("Message")
message.Text = playerName .." has won!"
message.Parent = game.Workspace
wait (2)
message.Destroy()
end
Upon running this function, or more specifically the "message.Destroy" command, I get the error: Error in script: '=' expected near '< eof >'
I have never seen this error before, and the ROBLOX wiki page on Lua errors doesn't mention it.
I would very much appreciate help in this, because I don't personally know anyone who has coded in Lua.
Looks like a syntax error. message.Destroy() should be message:Destroy() according to this Roblox wiki page http://wiki.roblox.com/index.php?title=API:Class/Instance/Destroy
Also see the section Explosions, Messages, and More at URL http://wiki.roblox.com/index.php?title=Basic_Scripting which provides similar syntax using the colon (:) operator.
See also Difference between . and : in Lua and explanation of "possible side-effects of calculations/access are calculated only once" with colon notation.
Instead of message.Destroy() it should be message:Destroy()
Remember that '.' are used directory-wise and ":' are used for inbuilt functions.
WOOOOOOOO! It was a syntax error. The correct command is message:Destroy. Cause why would object.Destroy work and message.Destroy not?
I am trying to write code to read a Ruby script entered by the user and stored it in a temp file, then pass that temp file to jruby -c temp_file to do syntax validation.
If any errors are found, I have to show the errors, along with the script entered by the user with line numbers.
How would I do this?
If there is a syntax error you see the failing line number:
blah.rb:2: syntax error, unexpected '.'
So just split your script on newline (\n) and thats your error line (1 index based of course).
If I understand correctly what you are trying to achieve, you can use jruby-parser (install gem install jruby-parser) with JRuby to find line numbers where errors occur:
require 'jruby-parser'
# Read script file into a String
script = File.open('hello.rb', 'r').read
begin
JRubyParser.parse(script)
rescue Exception => e
# Display line number
puts e.position.start_line
# Display error message
puts e.message
end
I have given up tryng to figure out the reason of this issue, but here is the story and hope you could give a tip...
As I develop unique app ( http://code.google.com/p/sedev ) and therefore I need to polish it.
I have to add File Summary ( very useful info in my opinion ) to any created files by the app, so I decided to go with NTFS compatible structure
edit: code snippet in which problem occurs:
if (FileExists(BaseLocation + LeftStr(GetSSWData, Length(GetSSWData)
- 1) + '.vkp') = True) then // add NTFS descriptive information to output file
try
SetFileSummaryInfo
(PWideChar(BaseLocation + LeftStr(GetSSWData, Length
(GetSSWData) - 1) + '.vkp')); // in my testcase files full path is: C:\Documents and Settings\Kludge\Desktop\sedevrpg\SEDEV_RPG_O_710.vkp
ShowMessagePos('Patch Created successfuly!' + #13#13 +
'Please verify created data to www.se-developers.net.',
ParamStr2X, ParamStr3Y);
MessageBeep(0);
except // exception handler does not even fire on exception ...
on Exception do
begin
if (WarningChBx.Checked = True) then
ShowMessagePos
('Unable to add Description to Output file (' +
BaseLocation + LeftStr(GetSSWData, Length(GetSSWData)
- 1) + '.vkp )', ParamStr2X, ParamStr3Y);
MessageBeep(0);
end;
end
final edit by author: Problem was in SetFileSummaryInfo(PWideChar('')) because after PWideChar conversion you got CHARACTER, not Array of Characters ( aka Strings ) therefore it is not valid path anymore!
Here is main tutorial: http://www.delphipages.com/articles/setting_file_summary_information-9228.html
edit: a better formatted tutorial is here.
BUT, the thing is that I just cannot get that damned FileName param to accept any string ... I have EOleSysError exception: "%1 cannot be found" no matter what.
Faulting operand is:
OleCheck(StgOpenStorageEx(PWideChar(FileName),
STGM_SHARE_EXCLUSIVE or STGM_READWRITE,
STGFMT_ANY,
0, nil, nil, #IID_IPropertySetStorage, stg));
What I do not understand is why it actually wants %1 MSDOS file name input.
I am not launching app from CMD therefore I highly doubt it needs additional param for File path ...
I have tried all possible String and PString conversions, also tried various param passing methods ... It just does not work ...
Any help appreciated!
I can only reproduce your case by specifying an invalid filename. Make sure that you include the full path in your filename.