Remove blank space at the beginning and end of a text (not in between) - flutter

I have a chat app, and I want to remove blank space from user input at the beginning and at the end of a message.
so -> "BLANKSPACE hi my name is BLANKSPACE Matthias BLANKSPACE"
should be "hi my name is BLANKSPACE Matthias".
Thanks in advance.

What you want to do is called trimming.
In flutter (which uses dart) you can use:
'\t hi my name is Matthias \n '.trim(); which will result in 'hi my name is Matthias'.
dart: String.trim()

Related

KFGQPC Uthmanic Script Hafs - Diacritical marks are not displayed properly

I'm using the KFGQPC Uthmanic Script HAFS - Font because it is the best looking font out there for my app. The only problem is, some characters are not displayed properly.
For example have a look at this:
The text, that should be displayed, looks like this:
أُو۟لَـٰٓئِكَ عَلَىٰ هُدًى مِّن رَّبِّهِمْ ۖ وَأُو۟لَـٰٓئِكَ هُمُ ٱلْمُفْلِحُونَ
Notice that circle (sukun) above the first و۟
If you ask which text I use to display the arabic text, its the following (in unicode):
\u0623\u064f\u0648\u06df\u0644\u064e\u0670\u0653\u0626\u0650\u0643\u064e \u0639\u064e\u0644\u064e\u0649\u0670 \u0647\u064f\u062f\u064b\u06ed\u0649 \u0645\u0651\u0650\u0646 \u0631\u0651\u064e\u0628\u0651\u0650\u0647\u0650\u0645\u0652 \u06d6 \u0648\u064e\u0623\u064f\u0648\u06df\u0644\u064e\u0670\u0653\u0626\u0650\u0643\u064e \u0647\u064f\u0645\u064f \u0671\u0644\u0652\u0645\u064f\u0641\u0652\u0644\u0650\u062d\u064f\u0648\u0646\u064e
Any suggestions?
Replace all Unicode characters of \u{06DF} ◌۟ with \u{0652} ◌ْ and that symbol will be replaced by Sukoon. In the text you are using instead of Sukoon upper Zero is used. That is why you see such problem.
Salam ,
I really had the same problem , but i used KFGQPC Uthmanic Taha Naskh on Excel , when i changed to KFGQPC Uthmanic Script HAFS , the display is correct .
I did arabic as the first language of display !

Why can not separate text lines in Telegram?

I created an EA in MQL4 where I send a text to be displayed as 3 lines of text in Telegram where each line is ended with \n as follows:
message = "Line one\n" +
"Line two\n" +
"Line three";
But somehow, the message are shown in Telegram as 1 single line, concatenating all the 3 lines.
I think \n is not recognized by Telegram. I am not sure what kind of characters should be used to create a line break.
Can anyone provide some help for me on how to separate each lines so it is shown neatly in Telegram message?
Thank you.
Alvin
Try adding \r\n to your text instead of just \n.

How can i get the first typed letter after empty space("") from UITextView in iPhone?

I want to get the last word from the typed sentence in UITextView. For example "Apple i", from this example i need to get the last letter 'i' coming after " "(empty space). I want to do the functionality while the user typing in UITextView. How can i get the users first letter of the word after from empty space(" ")? Can anyone please help to solve this problem? Thanks in advance.
Here is the string logic.
return [[textView.text componentsSeparatedByString:#" "] lastObject];
You can put this check in your UITextViewDelegate method textView:shouldChangeTextInRange:replacementText:. Don't forget to return YES here. You could also use textViewDidChange:.

Line break in Facebook status update via Graph API

I'm writing a simple Facebook status update web app that uses Graph API. It works well except for when I'd like to include a line break in the status message. I've tried adding a simple HTML tag, but this is just rendered as text.
Anyone know if this is possible, and if so, how?
It sounds silly, but this works:
Insert <center></center> where you would normally put <br>.
\r\n seems to work just fine to get line breaks in facebook
If you're using PHP or any language just add chr(10) and this will add a break :)
ASCII Solution :P
Please observe the new line that is used in the below code (an enter is hit inside the editor), that serves the purpose of adding new line to a post at a specific location:
$fb_status_with_new_line = "Text before new line" . "
" . "Text after new line";
If you replace return characters (\r) with new line characters (\n) you can achieve the desired result.
Enjoy...
%0A might work, i think i used that on one of my apps before.
HTML Decimal:
HTML Hexadecimal:
Java Hexadecimal: \u000A (Common To Javascript)
URL Hexadecimal: %0A
Escape Sequence: \n
HTML tag : <br>
Hope these come in handy :)
As of Dec 2013, this works (break lines in code):
$facebook->api('/me/feed', 'post', array('message'=> 'Line 1
Line 2
Line 3
Line 4',
'cb' => ''));
I've tried <center></center> it didn't work.
I've tried <br> it didn't work.
I've tried with invisible html characters, it didn't work.
I've tried with '\n' it didn't work.
However when I used "\n" instead of '\n' it worked. But this was recognized directly by the php before it was uploaded to facebook. So my suggestion is using double quotes with string messages in facebook posts.
If you are using PHP, you can do like this:
$message = str_replace('\r\n', "\n", $message); // input is from textarea
$ret_obj = $facebook->api('/me/photos', 'POST', array(
'source' => '#' . $photo['file_source'],
'message' => $message)
);
Please use double quote "\n" instead '\n'
\n Worked Its smallest an easiest way to add line breaks
You need to add carriage return i.e \n\r because facebook accept only enter for new line.
\n works. You just need to add it to the message param
\n working I checked now on twitter.
$post = $connection->post('statuses/update', array('status' => "first line \n second line"));
Just do it like so, It will work for other social media also
I use the messenger API with PHP.
For me, the string '\n' is working.
Beware that this is not the newline character (aka "\n").
No, it's '\' followed by 'n', aka "plain antislash-N".
if You are using iOS mobile platform the \n will supports fine.. message = encodeURIComponent(message) .. bur for android nothing is working for me searching for me..
None of the solutions offered worked for me when trying to post a comment on Facebook using Chrome. The only solution I have found is to highlight text that has a linefeed, then paste in that text, then erase all of the paste except the linefeed.
In my case (in bash) newline works only with newline character $'\n', e.g.
echo "Message text"$'\n'"#kw"

UITextField displays extra dot at the end of text

I saw a very strange issue with UITextField control. When typing in UITextField after typing a few characters when typing space characters it puts "." characters at the end of the string.
Can anyone know possible solution for this??
Thanks,
Jim.
Do you mean when you enter 2 spaces? If so this a feature that means you don't need to switch to the numeric keyboard to enter the full stop