How to get zeros from input field in android studio (Kotlin) - kotlin

I am having a problem, I want for example to take 0001 from input to convert it to 1110 and all I get is 1.
xml:
<com.google.android.material.textfield.TextInputEditText
android:id="#+id/binInput"
android:digits="01"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fontFamily="sans-serif-smallcaps"
android:inputType="number"
android:textColor="#color/black"
android:textSize="20sp"
android:typeface="sans" />
Text is received by
binInput.text.toString()
Can someone help me?

Related

converting xsl-fo to pdf middle dot encoding is not recognized

I am looking for a way to print a list with middle dot.
I am using an xsl file to convert it in a pdf file.
Below is a sample of my xsl file which lead to an unrecognized middle dot in my pdf file :
<?xml version="1.0" encoding="utf-8"?>
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" font-family="Calibri" >
<fo:layout-master-set>
<fo:simple-page-master master-name="FirstPage" margin-top="0.5cm">
<fo:region-body margin-top="6cm" margin-bottom="1.5cm" margin-left="2cm" margin-right="2cm" />
<fo:region-before extent="1cm" region-name="first-page-header"/>
<fo:region-after extent="1cm" region-name="first-page-footer" padding-left="1cm"/>
</fo:simple-page-master>
</fo:layout-master-set>
<fo:flow flow-name="xsl-region-body">
<fo:block>
<fo:inline font-family="Symbol">·</fo:inline>
</fo:block>
</fo:flow>
I have tried to include this symbol with "&#183", "&#xb7" and "& middot" but it does not succed.
I also tried to add encoding-mode="single-byte" next to font-family="Calibri" but still no success.
Any idea why it does not work ?
Drop the font-family="Symbol". At present, you are using the Symbol font for the · and not using Calibri, so changing the configuration for Calibri isn't going to change anything.
According to 'Character Map' on Windows 7, Symbol does not have a character at 0xB7 and Calibri has Middle Dot at 0xB7.
(If the purpose of the fo:inline is just to change the font, then you can also drop the fo:inline.)

TransferSpreadsheet builds invalid XLSX file if user customized decimal separator

In Microsoft Access 2016 (build 16.0.8201.2200), the VBA TransferSpreadsheet method is not working properly when the format of numbers in Windows 10 is customized, specifically, on computer with US region selected, if you swap "decimal symbol" and "digit grouping symbol" to be formatted like customary in Germany:
When I use TransferSpreadsheet to save a query, when I subsequently attempt to open that workbook in Excel, it says:
We have found some problem in some content in '...'. Do you want us to try to recover as much as we can?
When I do, I get the following warning:
Excel was able to open the file by repairing or removing the unreadable content.
When I look at the contents of the XLSX contents, I'm not surprised it's having a problem, because the internal XML is not well-formed. Because I've replaced the decimal separator to be "," in Windows, it's creating the numbers in the XML with commas, not decimal places. But XML standards dictate that regardless of your regional preferences, numbers in XML should use a "." as decimal symbol.
<worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships">
<dimension ref="A1:K20"/>
<sheetViews>...</sheetViews>
<sheetFormatPr defaultRowHeight="15"/>
<sheetData>
<row outlineLevel="0" r="1">...</row>
<row outlineLevel="0" r="2">
...
<c r="D2" s="0">
<v>2,9328903531E+16</v>
</c>
<c r="E2" s="0">
<v>5,404939826E+16</v>
</c>
<c r="F2" s="0">
<v>2,3923963705E+16</v>
</c>
...
</row>
...
</sheetData>
<pageMargins left="0.7" right="0.7" top="0.75" bottom="0.75" header="0.3" footer="0.3"/>
</worksheet>
While the "," might be the desired format for decimal symbol in the UI, the XLSX internal format must conform to XML standard, "." decimal symbol.
How do I solve this?
Bottom line, for the TransferSpreadsheet method to work correctly, if you want to change the formatting of numbers, do not use the "Customize Format" setting:
You should instead reset those values back to their defaults, and then select an appropriate region in the preceding dialog box, one that formats numbers as you prefer:
Having choosen a region that is formatted as desired, you thereby avoid the TransferSpreadsheet bug. When you do this, the spreadsheet will appear correctly in Excel:
But the XLSX will be formatted properly, too:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="x14ac" xmlns:x14ac="http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac">
<dimension ref="D3:F3"/>
<sheetViews>
<sheetView tabSelected="1" workbookViewId="0">
<selection activeCell="F12" sqref="F12"/>
</sheetView>
</sheetViews>
<sheetFormatPr defaultRowHeight="15" x14ac:dyDescent="0.25"/>
<cols>
<col min="4" max="6" width="26.85546875" style="1" bestFit="1" customWidth="1"/>
</cols>
<sheetData>
<row r="3" spans="4:6" x14ac:dyDescent="0.25">
<c r="D3" s="1">
<v>2.9328903531E+16</v>
</c>
<c r="E3" s="1">
<v>5.40493826E+16</v>
</c>
<c r="F3" s="1">
<v>2.3923963705E+16</v>
</c>
</row>
</sheetData>
<pageMargins left="0.7" right="0.7" top="0.75" bottom="0.75" header="0.3" footer="0.3"/>
</worksheet>

Handling 0x19 in XSLT 1.0

I have encountered a problem when input xml contains the character 0x19. I have created a demo xslt to reproduce the issue.
My demo xslt looks like this:
<?xml version="1.0" encoding="utf-8"?>
<xsl:transform version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl">
<xsl:output method="xml" indent="yes"/>
<xsl:param name="param1"/>
<xsl:template match="/">
<Value>
<xsl:value-of select="$param1"/>
</Value>
</xsl:template>
</xsl:transform>
I am passing the character 0x19 as param1. The below output gets generated.
<Value></Value>
which is an invalid xml. How can I get it right?
You are correct that
<Value></Value>
is not well-formed XML 1.0 - XML 1.0 does not allow any control characters below U+0020 except U+0009 (tab), U+000A (LF) and U+000D (CR), not even when expressed as numeric character references, so it is simply not possible to include that character in an XML 1.0 document. The processor is wrong to produce that output, it should raise an error to complain that you've tried to insert an illegal character in the output.
However it is well formed XML 1.1, which allows control characters as &# references but not as literals. If your processor supports this (and the donwnstream components that will be receiving your output support it too) then it may be sufficient to add version="1.1" to the xsl:output instruction
<xsl:output method="xml" indent="yes" version="1.1"/>
to tell it to output XML 1.1 instead of XML 1.0.

XSLT decimal-format causes exception

I am trying to use the xslt:decimal-format element, but I get the same error message whether I use my own code or the example code provided by w3schools.com. This is the w3 sample code:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:decimal-format name="euro" decimal-separator="," grouping-separator="."/>
<xsl:template match="/">
<xsl:value-of select="format-number(26825.8, '#,###.00', 'euro')"/>
</xsl:template>
</xsl:stylesheet>
And this is the XsltException it produces when I run it in Visual Studio 2010:
"Format '#,###.00' cannot have zero digit symbol after digit symbol after decimal point."
What's wrong on my side that causes this error?
You have changed the decimal format, called "euro" so that a valid number looks like this "1.232,99" (one thousand, two hundred and thirty two, point nine-nine in words). This does not match the format you have requested which is "#,###.00".
Change your format-number pattern to "#.###,00"

How can I load this XML data into Xcode?

Ok, so I've finally decided on how to load my data I'm going to go with loading my book data as an XML file. The problem is that I'm not too sure on where to start, I've heard terms such 'parsing' but dont know how exactly it fits in.
I have added the code below if someone could give me a start in the right direction I would really appreciate that, to begin with all I want to do is load one line with my own comment under that and then the next line and so on.
<myBook>
− <chapter index="1" name="Chapter Name">
<line index="1" text="line text here"/>
<line index="2" text=" line text here "/>
<line index="3" text=" line text here "/>
<line index="4" text=" line text here "/>
<line index="5" text=" line text here "/>
<line index="6" text=" line text here "/>
<line index="7" text=" line text here "/>
</chapter>
Thanks guys,
Maybe this questions helps you: Navigating XML from Objective-C
There a some classes with which you can process your XML file. If you don't know about XML in general, read the Wikipedia article about XML. The most common techniques that are used to process XML are also described there.
Use Cocoa's XML parser?
Apple's NSXMLParser is an event based based on libXML, it is a SAX parser. I have found it to be slow when parsing large files on the iPhone 3G as it doesn't take advantage of libXML's xmlParseChunk() function.
Have you thought about using JSON as an alternative?
Do you really mean "load into Xcode" or are you talking about reading your custom XML file in your application? And didn't you ask this as How To load XML file into iPhone project ?