I am pulling text from an embedded .txt file and then displaying it in a label. iOS is fine, but Android shows extra characters. I am missing something simple but not sure what. Thanks for the help.
This (in a .txt file):
0.2.3
- Fixed spelling errors
- Added version number in slide-out menu
- Squashed bugs
0.2.2
- Database Change Log Added.
- Bug Fixes.
0.2.1
- Bug Fixes
Turns into this:
The space characters are bring shown. How do I prevent this?
Retrieving the text:
var assembly = typeof(MainMenuViewModel).GetTypeInfo().Assembly;
Stream stream = assembly.GetManifestResourceStream("ReleaseNotes.txt");
var text = "";
using (var reader = new StreamReader(stream))
{
text = reader.ReadToEnd();
}
ReleseNotesText = text;
The Label:
<Label Text="{Binding ReleseNotesText}" HorizontalTextAlignment="Start" HorizontalOptions="Fill" VerticalOptions="CenterAndExpand" TextColor="{DynamicResource TextColor}" FontSize="18" />
More likely your newlines are \n in the embedded text file stream
Just convert them to the correct environment newline. Newline character(s) may vary depending on the running platform... in .NET you have the handy Environment.NewLine, thus:
ReleseNotesText = text.Replace("\n", Environment.NewLine);
Edit: after taking a look at the exact text file in the comments, it looks like it was using the U+2028 unicode sequence for newlines. The correct replacing code would be:
ReleseNotesText = text.Replace("\u2028", Environment.NewLine);
Related
So far I was parsing the NotesCalendarEntry ics manually and overwriting certain properties, and it worked fine. Today i stumbled upon a problem, where a long summary name of the appointment gets split into multiple lines, and my parsing goes wrong, it replaces the part up to the first line break and the old part is still there.
Here's how I do this "parsing":
NotesCalendarEntry calEntry = cal.getEntryByUNID(apptuid);
String iCalE = calEntry.read();
StringBuilder sb = new StringBuilder(iCalE);
int StartIndex = iCalE.indexOf("BEGIN:VEVENT"); // care only about vevent
tmpIndex = sb.indexOf("SUMMARY:") + 8;
LineBreakIndex = sb.indexOf(Character.toString('\n'), tmpIndex);
if(sb.charAt(LineBreakIndex-1) == '\r') // take \r\n into account if exists
LineBreakIndex--;
sb.delete(tmpIndex, LineBreakIndex); // delete old content
sb.insert(tmpIndex, subject); // put my new content
It works when line breaks are where they are supposed to be, but somehow with long summary name, line breaks are put into the summary (not literal \r\n characters, but real line breaks).
I split the iCalE string by \r\n and got this (only a part obviously):
SEQUENCE:6
ATTENDEE;ROLE=CHAIR;PARTSTAT=ACCEPTED;CN="test/Test";RSVP=FALSE:
mailto:test#test.test
ATTENDEE;CUTYPE=ROOM;ROLE=REQ-PARTICIPANT;PARTSTAT=ACCEPTED
;CN="Room 2/Test";RSVP=TRUE:mailto:room2#test.test
CLASS:PUBLIC
DESCRIPTION:Test description\n
SUMMARY:Very long name asdjkasjdklsjlasdjlasjljraoisjroiasjroiasjoriasoiruasoiruoai Mee
ting long name
LOCATION:Room 2/Test
ORGANIZER;CN="test/Test":mailto:test#test.test
Each line is one array element from iCalE.split("\\r\\n");. As you can see, the Summary field got split into 2 lines, and a space was added after the line break.
Now I have no idea how to parse this correctly, I thought about finding the index of next : instead of a new line break, and then finding the first line break before that : character, but that wouldn't work if the summary also contained a : after the injected line-break, and also wouldn't work on fields like that ORGANIZER;CN= as it doesn't use : but ;
I tried importing external ical4j jar into my xpage to overcome this problem, and while everything is recognized in Domino Designer it resulted in lots of NoClassDefFound exceptions after trying to reach my xpage service, despite the jars being in the build path and all.
java.lang.NoClassDefFoundError: net.fortuna.ical4j.data.CalendarBuilder
How can I safely parse this manually, or how can I properly import ical4j jar to my xpage? I just want to modify 3 fields, the DTSTART, DTEND and SUMMARY, with the dates I had no problems so far. Fields like Description are using literal \n string to mark new lines, it should be the same in other fields...
Update
So I have read more about iCalendar, and it seems that there is a standard for this called line folds, these are crlf line endings followed by a space. I made a while loop checking until the last line-break not followed by a space, and it works great so far. Will use this unless there's a better solution (ical4j is one, but I can't get it working with Domino)
In my Xamarin project I have a Label that formats a Date Value. I updated some Xamarin Nuget packages and now I'm getting the following error:
Strings containing { needs to be escaped. Start the string with
{}"
The Label on the page is a pretty simple StringFormat
<Label Text="{Binding Booking.ScheduledDeparture, StringFormat='{0:dd/MM/yyyy}'}"/>
Any ideas how I can resolve this error. I've tried adding # to the start of the StringFormat but that didn't work.
Add a {} before a string that starts with a { this should escape it. So '{}{0:dd/MM/yyyy}'.
For more documentation: https://learn.microsoft.com/en-us/dotnet/framework/xaml-services/escape-sequence-markup-extension
Is it possible to display the Euro symbol in pdfkit for nodejs without having to embed an external font?
I am using pdfKit to generate invoices and would like to prefix my currency amounts with the Euro Symbol (€).
I've tried a number of approaches and none worked:
doc.font('Helvetica-Bold')
.fontSize(12)
.text('€', 10, 10); // Alt+0128 on keypad
doc.font('Helvetica-Bold')
.fontSize(12)
.text('\u20AC', 10, 10);
Turns out it is a font issue:
unicode works, but you have to make sure that the font you are using
includes the characters you want to use. Unlike your operating system,
PDFKit does not do any automatic font substitution.
Source: Reddit Thread comment by /u/devongovett
I tested two fonts that were included with pdfkit. Both 'Helvetica-Bold' and 'Times-Roman' didn't work with the unicode symbols. I noticed in the documentation for fonts that you can add in your own fonts, so I gave the Cardo Font (hosted on Google Fonts) a go as it supports many unicode characters.
Sure enough, it worked. Here is the script I used for testing (Make sure you have the Cardo font available):
var PDFDocument = require('pdfkit');
var doc = new PDFDocument();
doc.registerFont('Cardo', 'Cardo/Cardo-Regular.ttf')
doc.font('Cardo')
.fontSize(20)
.text('Testing [\u20AC]', 10, 10);
doc.write('out.pdf');
If you're set on using Helvetica-Bold, download a copy of the font elsewhere (make sure it supports the unicode characters you're after) and register it as I have with the Cardo font.
I am using JSF 2.0 and I have text field as
<h:form>
<h:inputText value="#{myBean.myValue}" />
<h:commandButton value="Submit" action="#{myBean.printMe()}" />
</h:form>
public void printMe() {
System.out.println("first line==" + myValue + "==");
System.out.println("second line==يشسيبشسيبشسيبشيس==");
}
When I run this project and enter يشسيبشسيبشسيبشيس in textbox, in IDE console I see as below.
INFO: first line==????????????????==
INFO: second line==????????????????==
Any idea why this is happening?
This is caused by using the wrong console encoding.
The line
System.out.println("My Data is " + fullName);
prints to the standard output (stdout). You need to configure it to use UTF-8 as well. Assuming that you're using Eclipse, then you need to change the stdout encoding to UTF-8 by Window > Preferences > General > Workspace > Text File Encoding.
If you're using Netbeans, which I can't answer from top of head, head to this answer: hebrew appears as question marks in netbeans which contains a link to this Netbeans Wiki which mentions the following:
To change the language encoding for a project:
Right-click a project node in the Projects windows and choose Properties.
Under Sources, select an encoding value from the Encoding drop-down field.
See also:
Unicode - How to get the characters right?
Unrelated to the concrete problem, those lines in the filter are unnecessary
res.setCharacterEncoding("UTF-8");
res.setContentType("text/html;charset=utf-8");
They defaults in case of JSF2/Facelets to proper values already. Remove those lines.
If the data comes from a DB, please check the field datatype is nvarchar.
I am creating a WC_COMBOBOXEX on Windows Vista and adding strings to it, but they don't show up in the control. The same strings show up fine if I use the old WC_COMBOBOX with CB_ADDSTRING.
I am calling InitCommonControlsEx with ICC_USEREX_CLASSES and creating the comboboxex using CreateWindowEx with style WS_CHILD|WS_CLIPSIBLINGS|CBS_SIMPLE|CBS_SORT|CBS_HASSTRINGS (no extended styles). I am adding the strings using
COMBOBOXEXITEM cbem = {0};
cbem.mask = CBEIF_TEXT;
cbem.iItem = -1;
cbem.pszText = L"hello";
SendMessage(hWnd_, CBEM_INSERTITEM, 0, TOLPARAM(&cbem));
The combobox comes up empty but when I move the cursor up and down in the editcontrol/listbox, I see funny block characters sometimes.
Eventually, I want to add it as a CBS_DROPDOWNLIST to a rebar control but I read somewhere that comboboxex works a lot better in there than the old combobox.
Thanks.
From MSDN:
ComboBoxEx controls support only the following ComboBox styles:
CBS_SIMPLE
CBS_DROPDOWN
CBS_DROPDOWNLIST
WS_CHILD
So CBS_SORT and CBS_HASSTRINGS may be messing up the style bits.
Does it help if you send CBEM_SETUNICODEFORMAT?