I have a question about CKEditor, when I try to submit it to database, it become unreadable text (use Khmer unicode). I have tried to read other forum and I have found some solutions but, it still not work, I don't want to change to use other editor instead.
could anyone tell me.
Original text :
អង់គ្លេស៖ យោងតាមប្រភពព័ត៌មាន បានឲ្យដឹងថា ក្លិបបាល់ទាត់ តោខៀវ Chelsea របស់ប្រទេសអង់គ្លេស បានឈានជើង ចូលយ៉ាងជិត ក្នុងការទិញយក កីឡាករបាល់ទាត់ ដ៏ល្បីឈ្មោះ Lionel Messi ខណៈកីឡាករ រូបនេះ បានត្រៀមខ្លួន រួចជាស្រេច ក្នុងការ ចុះកុងត្រា ជាមួយក្លិបបាល់ទាត់ តោខៀវ Chelsea បន្ទាប់ពីឆ្អែតឆ្អន់ និងមិនសប្បាយចិត្ត ជាមួយនឹង ក្លិបបាល់ទាត់ Barcelona របស់ប្រទេសអេស្ប៉ាញ។
Result :
អង់គ្លáŸážŸáŸ– យោងážáž¶áž˜áž”្រភពពáŸážáŸŒáž˜áž¶áž“ បានឲ្យដឹងážáž¶ ក្លិបបាល់ទាážáŸ‹ ážáŸ„ážáŸ€ážœ Chelsea របស់ប្រទáŸážŸáž¢áž„់គ្លáŸážŸ បានឈានជើង ចូលយ៉ាងជិហក្នុងការទិញយក កីឡាករបាល់ទាážáŸ‹ ដáŸáž›áŸ’បីឈ្មោះ Lionel Messi ážážŽáŸˆáž€áž¸áž¡áž¶áž€ážš រូបនáŸáŸ‡ បានážáŸ’រៀមážáŸ’លួន រួចជាស្រáŸáž… ក្នុងការ ចុះកុងážáŸ’រា ជាមួយក្លិបបាល់ទាážáŸ‹ ážáŸ„ážáŸ€ážœ Chelsea បន្ទាប់ពីឆ្អែážáž†áŸ’អន់ និងមិនសប្បាយចិážáŸ’ហជាមួយនឹង ក្លិបបាល់ទាážáŸ‹ Barcelona របស់ប្រទáŸážŸáž¢áŸážŸáŸ’ប៉ាញ។
It's not the editor's issue, that's a charset issue during posting data via browser.
You need to add following meta tag in your HTML page:
<meta charset="utf-8" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
Another remark if your issue related to the database, you need also to set charset for your database (mysql) or also with using the right data type for the field of your database (ex: nvarchar for MS SQL Server etc.).
Related
I have an issue with <fo:footnote> when generating pdf/ua-1 document with fop.
The resulting pdf displays correctly the footnote in the page but don’t pass the pdf-ua validation. A severe error on pdf tag Note “id is missing” is raised so the document is not conformed. I'm using PAC3 for the conformance test.
In the example below I have extracted the basic <fo:footnote> element which has a unique id.
How can I generate the missing Id attribute in the pdf tagged Note element?
Here is the xsl-fo really simple footnote. Note that I used an id to reference the footnote.
some text...
<fo:footnote id="FNE0001">
<fo:inline font-size="6pt" baseline-shift="super">E0001</fo:inline>
<fo:footnote-body>
<fo:block>
<fo:inline>E0001</fo:inline><fo:inline > JO L 139 du 29.5.2002, p. 9.</fo:inline>
</fo:block>
</fo:footnote-body>
</fo:footnote> some text...
Apache FOP has been set to generate pdf-ua through the conf file as follow:
<renderers>
<renderer mime="application/pdf">
<!-- Before setting the pdf-ua-mode, we must insert metadata Title in FO declaration -->
<pdf-ua-mode>PDF/UA-1</pdf-ua-mode>
....
PAC3 is checking against the failure conditions in the Matterhorn Protocol; latest edition at https://www.pdfa.org/resource/the-matterhorn-protocol/.
PAC3 is probably reporting on failure condition 19-003, ID entry of the tag is not present.
fo:footnote-body can have an id property. You could try adding an ID to that. In the fo:inline for the footnote marker, you might also need to add an fo:basic-link that refers to that ID.
FWIW, your footnote does not cause that error when checking PDF/UA generated by AH Formatter, and I'm only guessing at what FOP would be doing differently. (PAC3 and I generally disagree when it complains about a footnote being a possibly incorrect use of a Note tag, but that's another story: PAC3 tries to automate checking the conditions that should be checked by a human, and it doesn't always get it right.)
say i have :
<pages>
<author>Me</author>
<copyright>me inc. 2015,</copyright>
<lastUpdate>2/1/1999</lastUpdate>
<Home>--------------------</Home>
<About>--------------------</About>
<Contact>------------------</Contact>
</pages>
i want two different xpath expressions that: 1. grabs all element between pages and home.
that is, author, copyright, lastUpdate and Home.
2.grabs all element between pages and Contact
excluding Home. that is author, copyright, lastUpdated
and About.
any guide please ?
1. //pages/*[(name() = 'Home') or following-sibling::Home]
2. //pages/*[not(name() = 'Home')]
I am parsing an html file using nokogiri and modifying it and then outputting it to a file like this:
htext= File.open(inputOpts.html_file).read
h_doc = Nokogiri::HTML(htext)
File.open(outputfile, 'w+') do |file|
file.write(h_doc)
end
The output file contains the first line as:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
I do not want this because I am embedding the html in a different file and this tag is causing issues.
Question is how do I remove this from h_doc.
Depending on what you are trying to do, you could parse your HTML as a DocumentFragment:
h_doc = Nokogiri::HTML::DocumentFragment.parse(htext)
When calling to_s or to_html on a fragment the doctype line will be omitted, as will the <html> and <body> tags that Nokogiri adds if they aren’t already present.
It depends on your needs. If all you need is the body then
h_doc.at_xpath("//body") #this will just pull the data from the <body></body> tags
If you need to collect the <head> too and just avoid the <DOCTYPE> then
#this will capture everything between the <head></head> and <body></body> tags
h_doc.xpath("//head") + h_doc.xpath("//body")
So something like this
h_doc = Nokogiri::HTML(open(input_opts.html_file))
File.open(outputfile,'w+') do |file|
#for just <body>
file << h_doc.at_xpath("//body").to_s
#for <head> and <body>
file << (h_doc.xpath("//head") + h_doc.xpath("//body")).to_s
end
Notice for body I used #at_xpath as this will return a Nokogiri::Element but when combining them I used #xpath becuase this will return a Nokogiri::XML::NodeSet. No need to worry this part is just for the combination and the html will come out the same e.g. h_doc.at_xpath("//head").to_s == h_doc.xpath("//head").to_s #=> true
You can just ignore the first line when reading the input file:
htext= File.readlines(inputOpts.html_file)[1..-1].join
h_doc = Nokogiri::HTML(htext)
File.open(outputfile, 'w+') do |file|
file.write(h_doc)
end
I managed to work around this with both an HTML::Document and an HTML::DocumentFragment.
For background, I'm using Nokogiri to parse and modify "templates", "partials" and/or "components" of HTML. This means that the files I encounter are not valid HTML documents. They are, instead, pieces of an HTML document that gets put together by the framework I'm using.
For reference, HTML::Document adds the <!DOCTYPE> declaration and also wraps your document into <html> and <body> entities if they are not already present in your document. Similarly, HTML::DocumentFragment will wrap your fragment with <p> entity.
Rather than spending too much time digging into the Nokogiri library code to understand where these additional entities were being, I decided to accept to this opinionated implementation and work around it.
Solution
Here's how I write out my modified HTML:
html_str = doc.xpath("//body").children.to_html(encoding: 'UTF-8')
File.open(_filename, 'w') {|f| f.write(html_str)}
Final Word
This seems harder than it should be. I even tried using the SaveOptions setting save_with: Nokogiri::XML::Node::SaveOptions::NO_DECLARATION to no avail.
In any case, while this solution is a bit kludgey for my liking, it works.
I'm building a website for a small store and want to implement schema.org-microdata-markup. The "problem": The store is opened from Tuesday till Friday – from 10:00 till 14:00 AND from 16:30 till 23:00 on these days. So I implemented the opening hours like this…
<time itemprop="openingHours" datetime="Tu-Fr 10:00-14:00, 16:00-23:00">XYZ</time>
But this way, the HTML-validator says…
Bad value Tu-Fr 10:00-14:00, 16:00-23:00 for attribute datetime on element time: The literal did not satisfy the time-datetime format.
How can I implement these multiple opening hours a day? Or is it impossible to do this with the <time>-tag and I have to change it to <meta>-tags? Thanks for your help! :-)
What if you used 2 entries for openingHours?
<time itemprop="openingHours" datetime="Tu-Fr 10:00-14:00">XYZ</time>
<time itemprop="openingHours" datetime="Tu-Fr 16:00-23:00">XYZ</time>
The LocalBusiness example has been updated to use <meta> elements:
<div itemscope itemtype="http://schema.org/Restaurant">
<span itemprop="name">GreatFood</span>
...
Hours:
<meta itemprop="openingHours" content="Mo-Sa 11:00-14:30">Mon-Sat 11am - 2:30pm
<meta itemprop="openingHours" content="Mo-Th 17:00-21:30">Mon-Thu 5pm - 9:30pm
<meta itemprop="openingHours" content="Fr-Sa 17:00-22:00">Fri-Sat 5pm - 10:00pm
</div>
The problem is the notations schema.org uses for openingHours are just not (yet) valid by the HTML5 spec for the time element.
You can copy all the examples from LocalBusiness in the Validator and they will all fail validation.
Until the spec contains a definition to write openingHours in a time element you will have to ignore the HTML validators I'm afraid.
BTW. The text on the schema.org site implies you could defines multiple times in one value:
The opening hours for a business. Opening hours can be specified as a weekly time range, starting with days, then times per day.
I recently ran in to the same issue and found that the second string of hours needs to be on another line like this:
<p><time itemprop="openingHours" datetime="Mo,Tu,We,Th, 08:30-13:30">M-Th 8:30am-12:30pm & 1:30pm-6:00pm</time>
<time itemprop="openingHours" datetime="Mo,Tu,We,Th, 14:30-18:00"></time></p>
It's also important to keep this code inside the closing tag, otherwise it will not register as being formatted correctly.
i have a page with this doctype:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN" "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd">
and converting it now to slim template format, bu slim has no such doctype in presets, and i suspect there should be way to specify custom one. Now i use |:
|<!DOCTYPE html PUBLIC "...skip...>
html
....
But it rendered without line break symbol after doctype line:
<!DOCTYPE html PUBLIC "...skip...><html ...
Which is undesired, any way to put them on separate lines ?
To insert a line break at any point in the template, just add this line:
= "\n"
The "=" command in Slim executes the given Ruby code and appends it to the buffer. In this case, the Ruby code is simply a newline character.
You don’t need the | character, Slim allows inline HTML for directly including HTML, and that includes doctypes. This doesn’t help with the formatting though, there is still no line break after it.
The doctypes are actually managed in Temple, which Slim uses. You could change this to add a custom doctype to get the behaviour you want. This does involve messing with Temple’s internal data so you need to be a little careful, especially when upgrading, as the internals may have changed.
The hash in question is has been frozen, so you can’t just add a new entry to it. You can however dup it, add an entry to the duplicated hash, and assign the new hash back to the constant. This will cause Ruby to generate a warning as you shouldn’t normally reassign constants this way.
new_hash = Temple::HTML::Fast::XHTML_DOCTYPES.dup
new_hash['rdf'] = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN" "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd">'
Temple::HTML::Fast::XHTML_DOCTYPES = new_hash
Now you can use rdf as if it was a predefined doctype in Slim.
doctype rdf
html
This produces:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN" "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd">
<html></html>
If you want to avoid seeing the warning, set $VERBOSE to nil before changing the constant (make sure you change it back afterwards).
begin
old_verbose, $VERBOSE = $VERBOSE, nil
Temple::HTML::Fast::XHTML_DOCTYPES = new_hash
ensure
$VERBOSE = old_verbose
end
(You could turn this into a method that accepts a block. If you’re using Rails it’s already been done for you with silence_warnings.)