String concatenation in solidity?

0 votes

how do i concatenate strings in solidity?

var str = 'asdf'
var b = str + 'sdf'

seems not to work..

I looked up the documentation (https://github.com/ethereum/wiki/wiki/Solidity-Tutorial#elementary-types-value-types) and there is not much mentioned about string concatenation. But it is stated that it works with the dot ('.') ?

"[...] a mapping key k is located at sha3(k . p) where . is concatenation."
Sep 21, 2018 in Blockchain by digger
• 26,550 points
566 views

1 answer to this question.

0 votes

library can be used, for example:

import "github.com/Arachnid/solidity-stringutils/strings.sol";

contract C {
  using strings for *;
  string public s;

  function foo(string s1, string s2) {
    s = s1.toSlice().concat(s2.toSlice());
  }
}
answered Sep 21, 2018 by slayer
• 29,170 points

Related Questions In Blockchain

+1 vote
2 answers

How to convert INT to STRING in Solidity?

Look at the following code : function uintToString(uint ...READ MORE

answered Jun 27, 2018 in Blockchain by Christine
• 15,790 points
1,171 views
0 votes
3 answers

String conversion to Array in Solidity

There is no built-in method/function for this ...READ MORE

answered Oct 3, 2018 in Blockchain by Charlie
259 views
+1 vote
1 answer

What is the difference between if() and require() statement in solidity??

If() and require() have separate functions and ...READ MORE

answered Apr 18, 2018 in Blockchain by Shashank
• 10,350 points
445 views
+1 vote
1 answer

what is use of msg.sender in solidity code?

msg.sender(address) function indicated the sender of the ...READ MORE

answered Apr 24, 2018 in Blockchain by Shashank
• 10,350 points
495 views
0 votes
1 answer

Truffle tests not running after truffle init

This was a bug. They've fixed it. ...READ MORE

answered Sep 11, 2018 in Blockchain by Christine
• 15,790 points
169 views
+1 vote
3 answers

Removing double quotes from a string from JSON response in PHP

Just remove the json_encode call, and it should work: $resp ...READ MORE

answered Sep 12, 2018 in Blockchain by digger
• 26,550 points
4,328 views
0 votes
1 answer
0 votes
1 answer

obfuscating and deobfuscating a string in JavaScript

You can use btoa() and atob(). btoa() is like base64_encode() and atob() like base64_decode(). Here is an example: btoa('Some ...READ MORE

answered Aug 23, 2018 in Blockchain by slayer
• 29,170 points
57 views